Repository navigation
ToggleGroupControl: Only show enclosing border when isBlock - #45492
Conversation
|
|
There was a problem hiding this comment.
Added this so it matches our "recommended default". (Note that isBlock is similarly enabled in our README code snippets.)
ciampo
left a comment
There was a problem hiding this comment.
Code changes LGTM 🚀
- never show the border (not even on hover or focus) when
isDeselectable === true(each option is a separate button and tab stop, with its own focus ring) - when
isDeselectable !== true:- always show border if
isBlock === true - show border only on hover / focus if
isBlock !== true
- always show border if
Let's wait for @jasmussen to have a look as well, though.
jasmussen
left a comment
There was a problem hiding this comment.
After:
At some point in the future, likely as part of the ongoing up-to-40px work that's going on, we'll want the height of all toggle states inside segmented controls, icon-only or not, to be 32px tall to match other similar elements such as these:

They are 30x30 now. But not a blocker at all, something we can look at separately. Thanks again!
Will do! Tracked in #45532 |
a980de6 to
ebe57b4
Compare


Follow-up to #45123
What?
When the control is unhovered or unfocused, change the logic so the enclosing border is hidden when
isBlockis false.Why?
We discussed with @jasmussen what a sensible style guideline would be regarding these enclosing borders.
The main requirement from the design team is that we don't want the visible border when the options are icons, or to be more exact, when they are square-proportioned like the buttons in the block toolbar.
In theory, non-icon options can also be square-proportioned when the text labels are short. And looking at @jasmussen's WIP mockups, it seems possible that not all icon buttons will be square-proportioned. But who knows what will happen. My assessment is that there's still a good amount of uncertainty on what our eventual product requirements are going to be here.
Hence, the main goal of this PR is to accomplish the border-hiding in a minimum viable way without mucking with the API prematurely. I see two approaches:
__experimentalIsBorderlessprop so consumers set it explicitly. The downside is that the consumers need to be aware of the style guideline, and when that guideline changes, they'll need to update all their instances.isBlockprop as a proxy to determine whether it needs a border. Looking at the Gutenberg codebase, all instances that use text options have theisBlockprop enabled. All instances with icon options have it disabled.I think number 2 is the minimum viable approach that will leave the least amount of tech debt down the line when requirements change and we need to change the API in some way. (This includes the possibility of splitting ToggleGroupControl into two components so one of them can handle the square-proportion case specifically.)
Testing Instructions
npm run storybook:devand see the stories/docs for ToggleGroupControl. The enclosing border (when unhovered & unfocused) should only be visible whenisBlock && ! isDeselectable.npm run devand smoke test some ToggleGroupControl instances in the editor sidebar.