Skip to content

DropdownMenu: Align group spacing and dividers with Menu - #87092

Merged
jameskoster merged 7 commits into
trunkfrom
update/dropdown-menu-align-with-menu
Nov 25, 2026
Merged

jameskoster merged 7 commits into
trunkfrom
update/dropdown-menu-align-with-menu

Conversation

@jameskoster

@jameskoster jameskoster commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

What?

Aligns the spacing and dividers of DropdownMenu in @wordpress/components with the Menu component in @wordpress/ui.

Why?

The two menus look noticeably different side by side. DropdownMenu pads each group by 8px and draws full-width dividers between them. Menu uses 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/ui surfaces), closing the gap makes them read as one system.

How?

The menu group rules already live in packages/components/src/dropdown/style.scss, shared by Dropdown and DropdownMenu. This change updates their values in place instead of adding separate rules for DropdownMenu, so nested popovers behave as they do on trunk. Any Dropdown that contains MenuGroups picks up the new spacing too. Those rules only target .components-menu-group, so dropdowns without groups are unchanged.

  • Padding: groups are padded by --wpds-dimension-padding-xs (4px) instead of 8px, and items outside a group get a 4px margin instead of 8px. A DropdownMenu without groups pads its popover by 4px too.
  • Group dividers: the full-width border-top between groups becomes a ::before line inset by --wpds-dimension-padding-sm, so it lines up with item labels, using --wpds-color-stroke-surface-neutral-weak (CanvasText in forced colors). Groups are separated by 4px + 1px + 4px, matching Menu's separator. hideSeparator still removes both the line and the gap. The is-alternate (toolbar) variant keeps its high-contrast $gray-900 line but is inset like the others.
  • controls dividers: the has-separator line in menus built from the controls prop gets the same inset, colour and spacing. Text items get 8px inline padding so their icons line up with MenuItem; icon-only items keep their 6px.
  • Group labels: inside a dropdown, match Menu's group label: 24px minimum height, 4px/8px padding, --wpds-color-foreground-content-neutral-weak, and the xs font size and line height tokens.

Not included: the $gray-900 divider MenuGroup uses outside of dropdowns, since that reaches beyond dropdowns.

Testing Instructions

  1. Open Storybook and compare Components / DropdownMenu / With children with Design System / Components / Menu / Grouped items. The padding, the gap between groups and the divider inset should match.
  2. In the editor, select a block and open the block toolbar's Options menu. Groups should be separated by inset dividers with tighter spacing, and items should be unchanged otherwise.
  3. Open a toolbar DropdownMenu built from controls with more than one control set (for example, a block's alignment or text formatting dropdowns) and check the divider between sets.
  4. Turn on a forced colors mode (e.g. Windows High Contrast, or DevTools' "Emulate CSS forced-colors: active") and check the dividers are still visible.
  5. Open a plain Dropdown that contains MenuGroups, such as an Image block's Duotone popover, and check its groups and labels use the same spacing.
  6. Toggle the Top toolbar setting to check the is-alternate variant.

Testing Instructions for Keyboard

  1. Select a block, press Alt+F10 to move to the block toolbar, then tab to Options and press Enter.
  2. Arrow through the menu. Each item should highlight as before, with nothing clipped by the reduced padding.

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 controls divider in the second row uses a has-separator item, since neither story shows one by default.

Before After
With children story DropdownMenu With children story before the change DropdownMenu With children story after the change, with a gap after Standalone Item
Block Options menu Block Options menu in the block toolbar before the change Block Options menu in the block toolbar after the change
Block Options menu, Top toolbar Block Options menu with Top toolbar on, before the change Block Options menu with Top toolbar on, after the change
Block switcher Image block switcher with Transform to and Styles groups before the change Image block switcher with Transform to and Styles groups after the change
Duotone popover Image block Duotone popover before the change Image block Duotone popover after the change

For reference, Menu from @wordpress/ui:

Use of AI Tools

Claude Code (Claude Opus 5.5) compared the two components, wrote the styles, measured the result against Menu in Storybook and drafted this description. I reviewed the change and checked it in Storybook and the editor.

🤖 Generated with Claude Code

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>
@github-actions github-actions Bot added the [Package] Components /packages/components label Nov 19, 2026
@github-actions

github-actions Bot commented Nov 19, 2026 •

Copy link
Copy Markdown

🤖 PR meta 🤖

Preview in WordPress Playground Preview in Storybook

🎉 Props

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

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>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.


Props Bot commands

You can trigger Props Bot actions by commenting on this PR:

  • @propsbot add <username> to give props to a GitHub user. Requires write access.
  • @propsbot remove <username> to leave a user out of the props. Requires write access.
  • @propsbot refresh to refresh this list. Adding the props-bot label works too.

Updated as activity occurs, without notifying anyone named here. Add the props-bot label to refresh.

📦 Bundle size

Size Change: +873 B (+0.01%)

Total Size: 8.71 MB

📦 View Changed
Filename Size Change
build/styles/components/style-rtl.css 18.5 kB +232 B (+1.27%)
build/styles/components/style-rtl.min.css 15.6 kB +208 B (+1.35%)
build/styles/components/style.css 18.6 kB +227 B (+1.24%)
build/styles/components/style.min.css 15.7 kB +206 B (+1.33%)

e566606 Run

⚡ Performance

Show the results

Client side metrics exclude the server response time.

front-end-block-theme

Metric 10840c2 trunk % Change
timeToFirstByte 43.7 ms +5.84% -3.89% 44.5 ms +5.84% -5.17% -1.8%
largestContentfulPaint 70 ms +2.86% -2.86% 72 ms +5.56% -5.56% -2.78%
lcpMinusTtfb 25.4 ms +22.05% -9.65% 26.3 ms +12.74% -10.65% -3.42%
wpBeforeTemplate 22.38 ms +7.06% -2.46% 22.63 ms +2.87% -2.92% -1.1%
wpTemplate 17.59 ms +4.89% -4.72% 18 ms +4.89% -5.22% -2.28%
wpTotal 39.92 ms +5.41% -2.93% 40.96 ms +6.25% -4.86% -2.54%
wpMemoryUsage 7.75 MB +0% -0% 7.72 MB +0% -0% 0.45%
wpDbQueries 16 +0% -0% 16 +0% -0% 0%

front-end-classic-theme

Metric 10840c2 trunk % Change
timeToFirstByte 36.8 ms +6.25% -5.03% 36.2 ms +8.01% -3.04% 1.66%
largestContentfulPaint 64 ms +6.25% -0% 64 ms +6.25% -0% 0%
lcpMinusTtfb 29 ms +2.93% -2.93% 28.5 ms +6.84% -4.56% 1.75%
wpBeforeTemplate 19.96 ms +6.11% -3.21% 19.55 ms +8.44% -2.46% 2.1%
wpTemplate 13.44 ms +5.73% -5.65% 13.33 ms +6.08% -3.38% 0.83%
wpTotal 33.53 ms +7.75% -3.73% 33.39 ms +9.07% -4.4% 0.42%
wpMemoryUsage 6.44 MB +0% -0% 6.41 MB +0% -0% 0.56%
wpDbQueries 13 +0% -0% 13 +0% -0% 0%

media-processing

Metric 10840c2 trunk % Change
mediaProcessingJpeg 326.63 ms +0.47% -0.58% 325.61 ms +1.71% -0.61% 0.31%
mediaProcessingAvif 4839.67 ms +0.49% -0.3% 4849.29 ms +0.22% -0.16% -0.2%
mediaProcessingJpegToAvif 3387.85 ms +0.26% -0.48% 3391.97 ms +0.44% -0.4% -0.12%

media-upload

Metric 10840c2 trunk % Change
jpegUploadProcessing 1469.79 ms +1.51% -2.09% 1446.74 ms +0.82% -0.14% 1.59%
pngUploadProcessing 246.57 ms +4.85% -2.73% 244.37 ms +2.69% -2.95% 0.9%
largeJpegUploadProcessing 1440.47 ms +0.97% -0.48% 1445.3 ms +0.94% -1.28% -0.33%
multipleImageUploadProcessing 1532.11 ms +1.39% -0.92% 1515.49 ms +2.47% -0.87% 1.1%

post-editor

Metric 10840c2 trunk % Change
serverResponse 287.37 ms +13.08% -1.21% 330.6 ms +1.18% -12.68% -13.08%
firstPaint 367.16 ms +4.21% -11.03% 310.23 ms +14% -5% 18.35%
domContentLoaded 652.48 ms +0.78% -2.12% 643.49 ms +1.34% -1.29% 1.4%
loaded 653.39 ms +0.77% -2.14% 644.4 ms +1.33% -1.31% 1.4%
firstContentfulPaint 368.7 ms +3.78% -2.86% 359.51 ms +1.87% -1.15% 2.56%
firstBlock 1751.52 ms +7.68% -0.65% 1727.92 ms +1.18% -1.18% 1.37%
type 14.99 ms +3.94% -13.14% 14.59 ms +3.36% -11.38% 2.74%
typeWithoutInspector 15.12 ms +4.23% -12.5% 14.44 ms +3.88% -10.87% 4.71%
typeWithTopToolbar 18.57 ms +5.55% -10.29% 18.96 ms +2.64% -9.39% -2.06%
typeContainer 6.69 ms +2.39% -12.71% 6.96 ms +3.45% -11.93% -3.88%
focus 84.87 ms +2.9% -4.29% 80.67 ms +2.31% -1.36% 5.21%
firstFocus 205.32 ms +0% -0% 208.65 ms +0% -0% -1.6%
selectAll 307.84 ms +1.6% -2.57% 299.32 ms +2.78% -1.27% 2.85%
undo 23.25 ms +8.82% -1.42% 24.11 ms +5.23% -5.64% -3.57%
listViewOpen 29.35 ms +9.68% -4.87% 29.99 ms +5.64% -9.47% -2.13%
inserterOpen 32.6 ms +4.39% -10.18% 31.22 ms +17.97% -6.15% 4.42%
inserterHover 9.15 ms +6.89% -7.65% 9.14 ms +5.36% -3.5% 0.11%
inserterSearch 6.89 ms +5.52% -5.81% 6.5 ms +11.69% -5.38% 6%
loadPatterns 500.48 ms +2.55% -1.01% 487.93 ms +5.21% -1.54% 2.57%
wpTotal 278.77 ms +13.47% -1.21% 321.42 ms +1.39% -12.82% -13.27%
wpMemoryUsage 14.81 MB +0% -0% 14.76 MB +0% -0% 0.33%
wpDbQueries 55 +0% -0% 55 +0% -0% 0%

site-editor

Metric 10840c2 trunk % Change
serverResponse 475.94 ms +8.28% -3.99% 495.04 ms +1.36% -7.77% -3.86%
firstPaint 461.03 ms +7.03% -8.75% 441.02 ms +11.91% -5.87% 4.54%
domContentLoaded 900.43 ms +1.77% -1.51% 888.54 ms +0.59% -0.34% 1.34%
loaded 901.62 ms +1.77% -1.52% 889.67 ms +0.57% -0.36% 1.34%
firstContentfulPaint 505.32 ms +1.56% -1.91% 492.81 ms +1.87% -3% 2.54%
firstBlock 2864.78 ms +0.33% -3.58% 2772.69 ms +2.85% -1.22% 3.32%
type 20 ms +8.1% -2.25% 20.06 ms +13.51% -11.91% -0.3%
navigate 126.62 ms +4.94% -1.45% 118.72 ms +10.07% -3.29% 6.65%
loadPatterns 1623.15 ms +2.74% -6.06% 1402.98 ms +13.88% -11.59% 15.69%
loadPages 1015.21 ms +5.2% -1% 1022.82 ms +1.36% -2.32% -0.74%
wpTotal 465.85 ms +8.49% -4% 485.26 ms +1.38% -7.96% -4%
wpMemoryUsage 12.84 MB +0% -0% 12.80 MB +0% -0% 0.28%
wpDbQueries 45 +0% -0% 45 +0% -0% 0%

e566606 Run

🏁 Flaky tests

Some 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 /test/e2e/specs/editor/collaboration/collaboration-stress.spec.ts, passed after 1 failed attempt.
TimeoutError: locator.waitFor: Timeout 17500ms exceeded.
Call log:
  - waiting for getByRole('button', { name: /Collaborators list/ }) to be visible

    at map (/home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/collaboration/fixtures/collaboration-utils.ts:193:7)
    at CollaborationUtils.waitForMutualDiscovery (/home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/collaboration/fixtures/collaboration-utils.ts:188:10)
    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/collaboration/collaboration-stress.spec.ts:416:28

e566606 Run

…pdate/dropdown-menu-align-with-menu

# Conflicts:
#	packages/components/CHANGELOG.md
@jameskoster jameskoster added the [Type] Enhancement A suggestion for improvement. label Nov 19, 2026
@jameskoster
jameskoster marked this pull request as ready for review November 19, 2026 12:52
@jameskoster
jameskoster requested a review from a team as a code owner November 19, 2026 12:52
@jameskoster
jameskoster requested a review from a team November 19, 2026 12:52
@github-actions
github-actions Bot requested review from aduth and ciampo November 19, 2026 12:52

@ciampo ciampo left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 ciampo left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 mirka left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@jameskoster

jameskoster commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor Author

The complexity mostly comes from giving DropdownMenu different rules from plain Dropdown, which then needs exclusions for every nesting case.

A smaller alternative approach: change the values in the existing Dropdown menu group rules (4px spacing, an inset token-based divider, token label styles), and keep the controls divider tweak in DropdownMenu's own stylesheet. No exclusions, no Popover DOM assumptions, and nesting behaves as on trunk.

The trade-off is that plain Dropdowns containing MenuGroups change too. Those rules only target .components-menu-group, so that only affects dropdowns already acting as menus. WDYT?

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>
@ciampo

ciampo commented Nov 20, 2026

Copy link
Copy Markdown
Contributor

The new approach feels like a better compromise, although let's wait for Lena's take.

@jasmussen

Copy link
Copy Markdown
Contributor

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.

@jameskoster

Copy link
Copy Markdown
Contributor Author

@jasmussen the changes here are just about the padding and divider indentation, to align with ui/Menu. No divider is removed. The screenshots are from this story which is a little confusing—I'm not sure we should encourage consumers to set up 'standalone item's like this without a divider. Like you said it looks broken.

@mirka mirka left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For reference, this is what I see at the current head:

Before After
With children story DropdownMenu With children story before the change DropdownMenu With children story after the change, with a gap after Standalone Item
Block Options menu Block Options menu in the block toolbar before the change Block Options menu in the block toolbar after the change
Block Options menu, Top toolbar Block Options menu with Top toolbar on, before the change Block Options menu with Top toolbar on, after the change
Block switcher Image block switcher with Transform to and Styles groups before the change Image block switcher with Transform to and Styles groups after the change
Duotone popover Image block Duotone popover before the change Image block Duotone popover after the change

…pdate/dropdown-menu-align-with-menu

# Conflicts:
#	packages/components/CHANGELOG.md
@jameskoster

Copy link
Copy Markdown
Contributor Author

What do y'all think @WordPress/gutenberg-design?

@jasmussen

Copy link
Copy Markdown
Contributor

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.

@jameskoster

Copy link
Copy Markdown
Contributor Author

I thought we all agreed on the indented dividers when we reviewed and updated Menu recently? 🙈

We should be consistent about this imo. I agree it's more apparent in the toolbar variant of DropdownMenu but I'm not convinced there should be an exception for this...

@jasmussen

Copy link
Copy Markdown
Contributor

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.

@jameskoster
jameskoster merged commit 43011aa into trunk Nov 25, 2026
88 checks passed
@jameskoster
jameskoster deleted the update/dropdown-menu-align-with-menu branch November 25, 2026 09:57
@github-actions github-actions Bot added this to the Gutenberg 24.6 milestone Nov 25, 2026
Vedant-Gandhi pushed a commit to Vedant-Gandhi/gutenberg that referenced this pull request Nov 30, 2026
…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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Package] Components /packages/components [Type] Enhancement A suggestion for improvement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants