+
Skip to content
This repository was archived by the owner on Oct 14, 2025. It is now read-only.

Conversation

clintcs
Copy link
Collaborator

@clintcs clintcs commented Dec 17, 2024

🚀 Description

Button Group Button, to match Tab Group and Tree, now emits a "selected" event instead of "change" and "input" events.

So now we have form controls—which dispatch "change" and "input" events. And we have non-form controls—which dispatch "selected".

@ynotdraw and I talked about using "change" and "input" events across the board. But we felt those events were too strongly associated with form controls to be used elsewhere. Let me know if you disagree.

Additionally:

  • Button Group Button, to match native, no longer emits a "selected" event when selected programmatically.
  • Button Group Button no longer emits an event when already selected and space is pressed.

📋 Checklist

🔬 How to Test

Button Group's tests should have us covered. But you're welcome to add an event listener via DevTools and verify the changes.

📸 Images/Videos of Functionality

N/A

Copy link

changeset-bot bot commented Dec 17, 2024

🦋 Changeset detected

Latest commit: 350e26a

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@crowdstrike/glide-core Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@clintcs clintcs force-pushed the button-group-selected-event branch from 0ecc36d to 808dbd7 Compare December 17, 2024 21:31
Copy link
Contributor

@clintcs clintcs changed the title Rename Button Group's "change" and "input" events to "selected" Rename Button Group Button's "change" and "input" events to "selected" Dec 17, 2024
@clintcs clintcs force-pushed the button-group-selected-event branch 3 times, most recently from 6ccd5af to f30f924 Compare December 18, 2024 14:01
Comment on lines -246 to -251

event.target.dispatchEvent(new Event('change', { bubbles: true }));

event.target.dispatchEvent(
new Event('input', { bubbles: true, composed: true }),
);
Copy link
Collaborator Author

@clintcs clintcs Dec 18, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"- Button Group Button, to match native, no longer emits a "selected" event when selected programmatically."

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mind updating the JS Docs at the top of the file to reflect these updates? 🙏

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. Will do.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

const button = event.target.closest('glide-core-button-group-button');

if (button && !button.disabled) {
if (button && !button.disabled && !button.selected) {
Copy link
Collaborator Author

@clintcs clintcs Dec 18, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"- Button Group Button no longer emits an event when already selected and space is pressed."

button.selected = true;

button.dispatchEvent(
new Event('selected', { bubbles: true, composed: true }),
Copy link
Collaborator Author

@clintcs clintcs Dec 18, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added an event dispatch to each interactive selection after removing the one in #onSlotSelected so "selected" isn't dispatched when selected is changed programmatically.

@clintcs clintcs force-pushed the button-group-selected-event branch from f30f924 to dab2b8b Compare December 18, 2024 14:10
@clintcs clintcs force-pushed the button-group-selected-event branch from dab2b8b to 7c9939d Compare December 18, 2024 14:16
@clintcs clintcs marked this pull request as ready for review December 18, 2024 14:17
Copy link
Collaborator

@ynotdraw ynotdraw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we'll also want to update the storybook docs, eh?

Screenshot 2024-12-18 at 9 29 42 AM

Comment on lines -246 to -251

event.target.dispatchEvent(new Event('change', { bubbles: true }));

event.target.dispatchEvent(
new Event('input', { bubbles: true, composed: true }),
);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mind updating the JS Docs at the top of the file to reflect these updates? 🙏

clintcs and others added 3 commits December 18, 2024 09:32
Co-authored-by: Tony Ward <8069555+ynotdraw@users.noreply.github.com>
@clintcs
Copy link
Collaborator Author

clintcs commented Dec 18, 2024

I think we'll also want to update the storybook docs, eh?

Derp.

ebb993c

@clintcs clintcs merged commit 4ace46d into main Dec 18, 2024
7 checks passed
@clintcs clintcs deleted the button-group-selected-event branch December 18, 2024 15:51
@github-actions github-actions bot mentioned this pull request Dec 18, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载