-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Remove state from FontSizePicker #18224
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
Remove state from FontSizePicker #18224
Conversation
Font size select dropdown was copying selected value from props onto state, therefore it was not properly updated when the props changed. By removing the state and deriving it directly from props in render ensures the Dropdown has up to date value.
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.
@Clarity-89 Thanks for your contribution!
If I remember from the original review, the state was needed for a reason. Testing this branch in the storybook it looks like selecting 'Custom' from the <select> element has no effect, so perhaps that's the reason. I think that would need to be solved before this can be merged.
This component may also change in the future if the changes from #17926 are merged, so that's another thing to look out for.
|
@talldan thank you for the comments! I indeed missed the Regarding #17926, it seems like the prop signature of |
|
@Clarity-89 I think the main thing is that when the custom option is selected it retains selection. I'm not sure what custom size it could choose, that would seem quite arbitrary. It's definitely a tricky behaviour, not one that's particularly elegant. It may just be worth focusing efforts on getting #17926 merged, and then re-evaluating it afterwards. What do you think? |
@talldan that was my opinion as well, not sure how to make custom selection in that case act in a non-arbitrary way. I agree that we will probably have to come back to this functionality after #17926 is merged, but in the meanwhile do you think it would make sense to have a quick fix for the buggy behavior of the slider/select dropdown? I can modify the PR to use |
|
@Clarity-89 thank you for working on this bug fix. In the meantime, the root issue was fixed so we can close this PR. |
Description
Fixes #18211
In
FontSizePickerchanges made via slider or text input weren't reflected in the font size dropdown.This was happening because
FontSizePicker's font size dropdown was copying selectedvaluefrom props onto state, therefore it was not properly updated when the props changed. By removing the stateand deriving it directly from props in render ensures the Dropdown has up to date
value.How has this been tested?
npm run design-system:devFontSizePickersection.withSliderScreenshots
Types of changes
Bug fix (non-breaking change which fixes an issue)
Checklist: