fix(segmented button): Scale Segmented Button doesn't respect controlled selected state (#2166)#2384
Conversation
❌ Deploy Preview for marvelous-moxie-a6e2fe failed.
|
packages/components/src/components/segmented-button/segmented-button.tsx
Outdated
Show resolved
Hide resolved
|
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. |
…merge request comments
| selected: | ||
| segment.hasAttribute('selected') && segment.selected ? true : false, |
There was a problem hiding this comment.
We should keep this as it was, since any of hasAttribute and selected could be true. With HTML, they might look the same, but they are considered different. If the user sets the selected in the HTML tag, it could be parsed to any of this based on the framework it is being used.
There was a problem hiding this comment.
I didn´t get your point. hasAttribute returns only if the attribute exists or not https://developer.mozilla.org/en-US/docs/Web/API/Element/hasAttribute . If we would let it as it is, this means every segment should be selected which has the attribute selected. It doesn´t matter if the selected is false or true. This means the initial state will be ignored.
There was a problem hiding this comment.
The point is that segment.hasAttribute('selected' and segment.selected are not always aligned. It could be that the DOM element is directly changed with 'setAttributeor the DOM element object was changed with.selected` not always these two are the sam e
packages/components/src/components/segmented-button/segmented-button.tsx
Outdated
Show resolved
Hide resolved
packages/components/src/components/segmented-button/segmented-button.tsx
Show resolved
Hide resolved
packages/components/src/components/segmented-button/segmented-button.tsx
Outdated
Show resolved
Hide resolved
…and updated snapshot
|
LGTM. tnx for the great job |
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.