-
Notifications
You must be signed in to change notification settings - Fork 86
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(segmented button): Scale Segmented Button doesn't respect controlled selected state (#2166) #2384
base: main
Are you sure you want to change the base?
Conversation
❌ Deploy Preview for marvelous-moxie-a6e2fe failed.
|
@@ -99,6 +99,15 @@ export class SegmentedButton { | |||
this.setState(tempState); | |||
} | |||
|
|||
@Listen('scaleSelectionChanged') | |||
selectionChangedHandler() { |
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.
I think this will get fired to many times, since the segment being unselected and selected will fire this. so it might lead to other inconsistencies. As this would create an additional place for the segments state manipulation
the current setup communicates the selection of a segment using the 'scale-change' event to the parent semnet-button
I think it is better to use the same event for both the programmatic and click change of the selection state.
@Watch('selected') | ||
selectionChanged() { | ||
emitEvent(this, 'scaleSelectionChanged'); | ||
} | ||
|
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.
IMO the watch
approach seems promising, and it would be much better to have the scaleClick
event emit here on change of the 'selected' state. This makes the click and programmatic change of the selection land in the same place.
also run the lint and formatter npm command before you push your changes , otherwise the build pipeline will fail. Currently the preview deployment pipeline has some issues , but the build pipeline should work if you fix the linter and prettier issues. |
Fixes #2166
Reason for this issue was that segmented button has never known when selected segment has been changed. Therefore I had to send an event when segment was selected outside the scale component and react on this event in segment button.