Repository navigation
DropdownMenu: Align group spacing and dividers with Menu - #87092
Conversation
Tighten the popover and group padding, inset the dividers between groups and in the `controls` prop so they line up with item labels, and match the group label styles of the `Menu` component in `@wordpress/ui`. The rules are scoped to the DropdownMenu popover, since `Dropdown` doesn't always hold a menu. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
🤖 PR meta 🤖🎉 PropsIf you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. Props Bot commandsYou can trigger Props Bot actions by commenting on this PR:
Updated as activity occurs, without notifying anyone named here. Add the 📦 Bundle sizeSize Change: +873 B (+0.01%) Total Size: 8.71 MB 📦 View Changed
⚡ PerformanceShow the resultsClient side metrics exclude the server response time. front-end-block-theme
front-end-classic-theme
media-processing
media-upload
post-editor
site-editor
🏁 Flaky testsSome tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information. three users concurrently edit a large post with diverse blocks in
|
…pdate/dropdown-menu-align-with-menu # Conflicts: # packages/components/CHANGELOG.md
There was a problem hiding this comment.
Could we scope the existing group-spacing rules to plain Dropdown and let DropdownMenu set its own padding? That would let us drop the extra :has() selector and the rules that reset the margin and width of standalone menu items.
As a follow-up, the Query Loop pattern picker could use its own popover class. It shares one with the block Options menu, so the picker's mobile scrolling rule also applies to other expanded menus with that class. (Query toolbar, Query styles)
Limit the `Dropdown` menu group spacing rules to plain dropdowns so `DropdownMenu` sets its own padding without the `:has()` override or the margin and width resets for standalone items. Draw the divider between groups as an in-flow border, so groups no longer become the containing block for absolutely positioned children such as the block switcher preview, and the divider stays visible in forced colors in the toolbar variant. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A plain `Dropdown` rendered inline inside a DropdownMenu picked up the inset divider and lost its group top padding. Skip groups that sit inside another, non-DropdownMenu popover nested in the menu, wrapped in `:where()` so specificity is unchanged, and pad only the menu's own popover content. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ciampo
left a comment
There was a problem hiding this comment.
LGTM 🚀
The alignment and text-formatting menus each use a single control set, so neither shows the divider in step 3. Could we use the default DropdownMenu story and split its controls into two arrays, for example controls={ [ [ { title: 'First' } ], [ { title: 'Second' } ] ] }?
A grouped DropdownMenu rendered inline inside a plain Dropdown picked up the outer popover's group padding, borders and standalone item margins. Pad only the dropdown's own popover content, and skip groups inside a nested DropdownMenu, wrapped in `:where()` so specificity is unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
mirka
left a comment
There was a problem hiding this comment.
This seems to require a cost/benefit decision similar to what was necessary in #85861.
The parts where we simply replace values with CSS tokens are cheap, but most of the added complexity here is scoping. Dropdown now excludes DropdownMenu, and DropdownMenu excludes popovers nested inside it. This kind of intertwined CSS is something I would be hesitant to touch later. It also ties these components more closely to the Popover DOM structure, when it's quite possible that we will soon try to (or need to) replace the DropdownMenu popover with a @wordpress/ui popover.
I think we should be careful not to overdo these consistency tweaks so we don't keep adding more complexity to components we're trying to move away from. There is probably a smaller changeset in here that gives us most of the consistency while cutting most of the complexity.
|
The complexity mostly comes from giving A smaller alternative approach: change the values in the existing The trade-off is that plain Edit: I pushed this so we can review. |
Change the values in the existing Dropdown menu group rules instead of giving DropdownMenu its own, so nested popovers need no exclusions. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
The new approach feels like a better compromise, although let's wait for Lena's take. |
|
I'm missing nuance this cold Monday. To me the after image looks obviously better than the before image, to the point that it looks like the bugfix. Is the nuance that the particular dropdown in question has a "spacer" between the first two items? Does this PR remove such a spacer in favour of only dividers? In any case, it seems valid to me. |
|
@jasmussen the changes here are just about the padding and divider indentation, to align with |
…pdate/dropdown-menu-align-with-menu # Conflicts: # packages/components/CHANGELOG.md
|
What do y'all think @WordPress/gutenberg-design? |
|
Thanks so much for the after shots. Eck, I need to sleep on this one, my immediate reaction is that I much prefer when the separator is full-menu-width. At the same time, one of the models we have compared with in the past is the MacOS menus, where dividers are also not full-width. But at the same time, they are much more muted, which looks especially off in the dark-border versions. All that is to say this could be cheese-moving aversion, not sure. |
|
I thought we all agreed on the indented dividers when we reviewed and updated We should be consistent about this imo. I agree it's more apparent in the toolbar variant of |
|
I don't recall where that happened. But it doesn't matter as it's a data-point of one, and not a strong opinion at that. I'm happy to try anything, because if we get revolts in the street we can always revisit. So go forth and conquer. |
…7092) Co-authored-by: jameskoster <jameskoster@git.wordpress.org> Co-authored-by: ciampo <mciampini@git.wordpress.org> Co-authored-by: mirka <0mirka00@git.wordpress.org> Co-authored-by: jasmussen <joen@git.wordpress.org>










What?
Aligns the spacing and dividers of
DropdownMenuin@wordpress/componentswith theMenucomponent in@wordpress/ui.Why?
The two menus look noticeably different side by side.
DropdownMenupads each group by 8px and draws full-width dividers between them.Menuuses a single 4px popup padding and dividers inset to line up with the item labels. Since both appear in the same screens (for example, the block toolbar next to newer@wordpress/uisurfaces), closing the gap makes them read as one system.How?
The menu group rules already live in
packages/components/src/dropdown/style.scss, shared byDropdownandDropdownMenu. This change updates their values in place instead of adding separate rules forDropdownMenu, so nested popovers behave as they do on trunk. AnyDropdownthat containsMenuGroups picks up the new spacing too. Those rules only target.components-menu-group, so dropdowns without groups are unchanged.--wpds-dimension-padding-xs(4px) instead of 8px, and items outside a group get a 4px margin instead of 8px. ADropdownMenuwithout groups pads its popover by 4px too.border-topbetween groups becomes a::beforeline inset by--wpds-dimension-padding-sm, so it lines up with item labels, using--wpds-color-stroke-surface-neutral-weak(CanvasTextin forced colors). Groups are separated by 4px + 1px + 4px, matchingMenu's separator.hideSeparatorstill removes both the line and the gap. Theis-alternate(toolbar) variant keeps its high-contrast$gray-900line but is inset like the others.controlsdividers: thehas-separatorline in menus built from thecontrolsprop gets the same inset, colour and spacing. Text items get 8px inline padding so their icons line up withMenuItem; icon-only items keep their 6px.Menu's group label: 24px minimum height, 4px/8px padding,--wpds-color-foreground-content-neutral-weak, and thexsfont size and line height tokens.Not included: the
$gray-900dividerMenuGroupuses outside of dropdowns, since that reaches beyond dropdowns.Testing Instructions
DropdownMenubuilt fromcontrolswith more than one control set (for example, a block's alignment or text formatting dropdowns) and check the divider between sets.Dropdownthat containsMenuGroups, such as an Image block's Duotone popover, and check its groups and labels use the same spacing.is-alternatevariant.Testing Instructions for Keyboard
Screenshots or screencast
Captured from Storybook. The group label in the first row was added to the story's markup for the screenshot, and the
controlsdivider in the second row uses ahas-separatoritem, since neither story shows one by default.For reference,
Menufrom@wordpress/ui:Use of AI Tools
Claude Code (Claude Opus 5.5) compared the two components, wrote the styles, measured the result against
Menuin Storybook and drafted this description. I reviewed the change and checked it in Storybook and the editor.🤖 Generated with Claude Code