-
Notifications
You must be signed in to change notification settings - Fork 7
Rename Button Group Button's "change" and "input" events to "selected" #543
Conversation
🦋 Changeset detectedLatest commit: 350e26a The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
0ecc36d
to
808dbd7
Compare
6ccd5af
to
f30f924
Compare
|
||
event.target.dispatchEvent(new Event('change', { bubbles: true })); | ||
|
||
event.target.dispatchEvent( | ||
new Event('input', { bubbles: true, composed: true }), | ||
); |
There was a problem hiding this comment.
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."
There was a problem hiding this comment.
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? 🙏
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch. Will do.
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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 }), |
There was a problem hiding this comment.
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.
f30f924
to
dab2b8b
Compare
dab2b8b
to
7c9939d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
||
event.target.dispatchEvent(new Event('change', { bubbles: true })); | ||
|
||
event.target.dispatchEvent( | ||
new Event('input', { bubbles: true, composed: true }), | ||
); |
There was a problem hiding this comment.
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? 🙏
Co-authored-by: Tony Ward <8069555+ynotdraw@users.noreply.github.com>
Derp. |
🚀 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:
📋 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