ToolsPanel: Update unchecked menu items to use empty icon to ensure enough whitespace#34375
ToolsPanel: Update unchecked menu items to use empty icon to ensure enough whitespace#34375andrewserong wants to merge 1 commit into
Conversation
|
@aaronrobertshaw, you might have had another idea for how to handle this, so happy to go with another option if you have a preferred approach 🙂 |
|
Size Change: +13 B (0%) Total Size: 1.04 MB
ℹ️ View Unchanged
|
aaronrobertshaw
left a comment
There was a problem hiding this comment.
Thanks for polishing this part of the ToolsPanel @andrewserong ✨
This works as advertised and is a nice touch.
I wonder about adding an empty SVG though to solely adjust something visually. I don't feel strongly, though I would probably lean towards just adding the following CSS rule to the ToolsPanelHeader definition in styles.js instead of the empty SVG approach.
.components-menu-item__button[aria-checked='false'] {
padding-right: ${ space( 14 ) };
}
The above CSS works for me in achieving the same result. What do you think?
|
Thanks Aaron! That’s a bit neater just adding in the CSS rule instead, sounds like a good approach, I’ll have a play with it tomorrow! |
|
Definitely should not need an empty svg, but we should also not need custom CSS scoped to this specific use. The dropdown menu component should be doing the spacing by default, and any improvements needed should be done there directly. cc @ciampo @jasmussen |
|
Thanks for the feedback Matias! I'll take a look at the |
|
Thanks for the feedback, folks! I've implemented the CSS approach upstream in the MenuItem component and raised a separate PR, happy for more feedback over there: #34406 — I think it's a neater approach keeping within that component, but again let me know if anyone has other ideas. I'll close out this PR now. |

Description
Noticed while testing #34065:
In the ToolsPanel component, if a longer ToolsPanelItem label is used and the item is unchecked, then its label encroaches upon the visual space that the check icon takes up in the menu.
In this change, we add an empty icon for unchecked menu items to ensure that the space surrounding the unchecked item is reserved for the presence (or in this case absence) of the icon. It also helps ensure that the width of the display options popover is the same when all items are unchecked as when they're all checked.
How has this been tested?
Via Storybook:
Go to http://localhost:50240/?path=/story/components-experimental-toolspanel--default and experiment with checking and unchecking the panel items.
Screenshots
With other items checked (note there isn't enough whitespace next to the third item):
With other items unchecked (note that in the before gif, the width of the popover is inconsistent between all items unchecked and one item checked)
Types of changes
(non-breaking change which fixes a styling issue)
Checklist:
*.native.jsfiles for terms that need renaming or removal).