-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
[Components - ToggleGroupControlOption]: Calculate width from button content and remove LabelPlaceholderView
#39345
Conversation
… content and remove `LabelPlaceholderView`
LabelPlaceholderView
LabelPlaceholderView
Size Change: -53 B (0%) Total Size: 1.16 MB
ℹ️ View Unchanged
|
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.
LGTM
So to sum up I think LabelPlaceholderView is completely obsolete
I had also concluded the same and removed it in a stale draft PR (also made for reasons tangential to the LabelPlaceholderView).
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.
So to sum up I think LabelPlaceholderView is completely obsolete - but feel free to correct me if I'm missing something. 😄
It does look like it. It'd be interesting to see when/why this was introduced, in order to understand this strange layout pattern.
The only difference that I can see is that each ToggleGroupOption
now looks slightly narrower:
toggle-group-control-diff.mp4
This is probably caused by the fact that the placeholder view (which was deleted in this PR) had font-weight: bold;
among its styles, which consequently made its text take more horizontal space — although I don't see it as an issue.
Thanks for the reviews!
I think this was just code written quite a long time ago, as part of the initial creation of g2 components and was ported this way. Similar case would be the aspectRatio component that it turned out we didn't need at all right now.
Right! If we want to tweak some styles there we should do it in the visible label and actually I think we discuss this in the
💯 |
I cherry-picked this PR into Gutenberg 12.8 release to prevent issues with the merge conflicts in the CHANGELOG file while publishing to npm with the automated script. |
…content and remove `LabelPlaceholderView` (#39345) * [Components - ToggleGroupControlOption]: Calculate widths from button content and remove `LabelPlaceholderView` * update changelog * fix tests
What?
I made a POC for adding
icon
support inToggleGroupControl
component and saw that we calculate the width of the labels in a weird and not proper way IMO. What we are doing now is having css for the main button that positionsabsolute
the element and centers it with atranslate
rule, and we useLabelPlaceholderView
which is not visible(visibility: hidden;
) but still in the document label to calculate the width. This seems wrong to me because:LabelPlaceholderView
. If we wanted to change that - like icons support - we cannot do that.LabelPlaceholderView
we also have aria-hidden which means the element is not exposed to an accessibility API, so it seems that it was just there for width calculation to me..So to sum up I think
LabelPlaceholderView
is completely obsolete - but feel free to correct me if I'm missing something. 😄Why?
Code quality change that will also enable us to add
icon
supportTesting Instructions
FontSizePicker
or inPostFeaturedImage
when you set aheight
, etc... Also check the stories in storybook.