Skip to content

Widgets: Migrate the Options menu to Menu from @wordpress/ui - #87622

Merged
t-hamano merged 12 commits into
trunkfrom
update/widgets-options-menu-ui-menu
Dec 3, 2026
Merged

t-hamano merged 12 commits into
trunkfrom
update/widgets-options-menu-ui-menu

Conversation

@t-hamano

@t-hamano t-hamano commented Nov 29, 2026 •

Copy link
Copy Markdown
Contributor

What?

Migrates the Options menus of the widgets editor and the widgets Customizer from DropdownMenu to Menu from @wordpress/ui, like the post and site editors.

Why?

The post and site editors already use Menu for their Options menu. This makes the widgets editors match them.

How?

  • Rewrites both menus with Menu, following the editor's Options menu.
  • Adds a local menu item for toggling preferences to each package. Neither package depends on @wordpress/editor, so they can't reuse its MoreMenuPreferenceItem and each needs its own component built with Menu.
  • Closes the Customizer menu when the preview iframe is clicked.

With this PR, PreferenceToggleMenuItem is no longer used anywhere in Gutenberg. Consumers can keep using it inside a DropdownMenu as before.

Testing Instructions

  1. Activate a classic theme, e.g. Twenty Twenty-One.
  2. Open Appearance > Widgets, and open the Options menu. Check that each item works.
  3. Open Appearance > Customize > Widgets > a widget area, and open the Options menu. Check that each item works.
  4. With the Options menu open in the Customizer, click the preview. Check that the menu closes.

Screenshots or screencast

###Widghets

Before After
before-widgets-hover after-widgets-hover

Customizer

Before After
before-customizer-hover after-customizer-hover

Use of AI Tools

This PR was authored with Claude Code, and reviewed by the author.

Migrate the Options menus of the widgets editor and the widgets
Customizer from DropdownMenu to Menu, like the post and site editors.
Remove the unused EditWidgetsToolsMoreMenuGroup slot, and close the
Customizer menu when the preview is clicked.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011g9URxg61iAc4ZxQiqFamu
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011g9URxg61iAc4ZxQiqFamu
@github-actions github-actions Bot added the [Package] Edit Widgets /packages/edit-widgets label Nov 29, 2026
@t-hamano t-hamano added [Type] Enhancement A suggestion for improvement. [Feature] Widgets Screen The block-based screen that replaced widgets.php. [Feature] Widgets Customizer Ability to add and edit blocks in Customize → Widgets. and removed [Package] Edit Widgets /packages/edit-widgets labels Nov 29, 2026
@github-actions

github-actions Bot commented Nov 29, 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: t-hamano <wildworks@git.wordpress.org>
Co-authored-by: Mamaduka <mamaduka@git.wordpress.org>
Co-authored-by: ciampo <mciampini@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: +113 kB (+1.3%)

Total Size: 8.85 MB

📦 View Changed
Filename Size Change
build/scripts/customize-widgets/index.min.js 79.3 kB +56.4 kB (+246%) 🆘
build/scripts/edit-widgets/index.min.js 85.8 kB +56.6 kB (+194.31%) 🆘
build/styles/customize-widgets/style-rtl.css 3.11 kB +22 B (+0.71%)
build/styles/customize-widgets/style-rtl.min.css 2.09 kB +16 B (+0.77%)
build/styles/customize-widgets/style.css 3.1 kB +23 B (+0.75%)
build/styles/customize-widgets/style.min.css 2.09 kB +15 B (+0.72%)
build/styles/edit-widgets/style-rtl.css 5.49 kB +15 B (+0.27%)
build/styles/edit-widgets/style-rtl.min.css 4.08 kB +19 B (+0.47%)
build/styles/edit-widgets/style.css 5.48 kB +15 B (+0.27%)
build/styles/edit-widgets/style.min.css 4.08 kB +15 B (+0.37%)

a75a30c Run

⚡ Performance

Show the results

Client side metrics exclude the server response time.

front-end-block-theme

Metric 5293336 trunk % Change
timeToFirstByte 60.6 ms +6.19% -2.89% 59.7 ms +1.26% -1.93% 1.51%
largestContentfulPaint 100 ms +2% -10% 92 ms +4.35% -4.35% 8.7%
lcpMinusTtfb 33.75 ms +16.74% -11.26% 29.8 ms +17.95% -5.2% 13.26%
wpBeforeTemplate 31.48 ms +9.24% -1.56% 31.25 ms +7.74% -1.98% 0.74%
wpTemplate 24.56 ms +5.09% -3.58% 23.58 ms +3.31% -3.52% 4.16%
wpTotal 56.36 ms +6.87% -2.36% 55.61 ms +1.71% -1.74% 1.35%
wpMemoryUsage 7.75 MB +0% -0% 7.72 MB +0% -0% 0.44%
wpDbQueries 16 +0% -0% 16 +0% -0% 0%

front-end-classic-theme

Metric 5293336 trunk % Change
timeToFirstByte 50.25 ms +7.96% -2.99% 48.6 ms +6.89% -0.72% 3.4%
largestContentfulPaint 88 ms +4.55% -4.55% 84 ms +4.76% -0% 4.76%
lcpMinusTtfb 36.5 ms +6.03% -3.56% 35.55 ms +2.81% -2.81% 2.67%
wpBeforeTemplate 28.39 ms +16.7% -1.3% 28.22 ms +5.88% -2.23% 0.6%
wpTemplate 17.9 ms +5.31% -3.91% 17.22 ms +6.33% -2.9% 3.95%
wpTotal 46.77 ms +8.92% -2.44% 45.38 ms +6.94% -0.62% 3.06%
wpMemoryUsage 6.44 MB +0% -0% 6.41 MB +0% -0% 0.55%
wpDbQueries 13 +0% -0% 13 +0% -0% 0%

media-processing

Metric 5293336 trunk % Change
mediaProcessingJpeg 404.26 ms +0.83% -0.4% 405.49 ms +0.2% -0.5% -0.3%
mediaProcessingAvif 6145.24 ms +0.48% -0.24% 6166.89 ms +0.38% -0.16% -0.35%
mediaProcessingJpegToAvif 4244.95 ms +0.37% -0.06% 4283.17 ms +0.29% -0.61% -0.89%

media-upload

Metric 5293336 trunk % Change
jpegUploadProcessing 2006.13 ms +2.06% -2.68% 1987.79 ms +1.36% -22.48% 0.92%
pngUploadProcessing 276.21 ms +5.34% -7.66% 284.08 ms +4.25% -3.46% -2.77%
largeJpegUploadProcessing 1983.49 ms +1.12% -22.15% 1992.38 ms +0.16% -21.17% -0.45%
multipleImageUploadProcessing 2117.22 ms +0.58% -0.11% 2116.96 ms +0.97% -0.53% 0.01%

post-editor

Metric 5293336 trunk % Change
serverResponse 323.52 ms +2.11% -10.57% 334.48 ms +0.21% -9.88% -3.28%
firstPaint 348.32 ms +9.07% -10.84% 366.06 ms +1.72% -15.59% -4.85%
domContentLoaded 650.54 ms +5.86% -0.7% 666.54 ms +0.62% -0.82% -2.4%
loaded 651.84 ms +5.87% -0.72% 667.89 ms +0.66% -0.81% -2.4%
firstContentfulPaint 378.22 ms +5.18% -3.61% 371.76 ms +2.61% -0.36% 1.74%
firstBlock 1789.22 ms +4.3% -2.32% 1805.73 ms +0.86% -0.44% -0.91%
type 15.06 ms +5.31% -14.01% 15.65 ms +4.92% -7.09% -3.77%
typeWithoutInspector 14.91 ms +3.42% -11.2% 15.25 ms +5.7% -10.03% -2.23%
typeWithTopToolbar 18.66 ms +10.24% -6.97% 19.58 ms +6.74% -11.8% -4.7%
typeContainer 7.2 ms +8.61% -3.47% 7.19 ms +4.31% -11.68% 0.14%
focus 90.55 ms +3.98% -4.87% 90.02 ms +3.53% -7.21% 0.59%
firstFocus 222.97 ms +0% -0% 210.23 ms +0% -0% 6.06%
selectAll 323.78 ms +1.38% -1.35% 308.44 ms +0.9% -2.92% 4.97%
undo 26.76 ms +4.97% -3.81% 24.97 ms +9.41% -4.08% 7.17%
listViewOpen 32.87 ms +5.66% -1.22% 31.06 ms +9.27% -6.21% 5.83%
inserterOpen 33.97 ms +3.33% -6.77% 33.58 ms +9.38% -6.43% 1.16%
inserterHover 10.22 ms +4.89% -10.57% 9.13 ms +9.2% -3.83% 11.94%
inserterSearch 7.53 ms +8.5% -4.12% 6.93 ms +5.77% -4.33% 8.66%
loadPatterns 524.46 ms +2.97% -1.84% 513.88 ms +3.9% -2.26% 2.06%
wpTotal 314.97 ms +2.14% -10.85% 325.46 ms +0.32% -10.08% -3.22%
wpMemoryUsage 14.80 MB +0% -0% 14.76 MB +0% -0% 0.25%
wpDbQueries 55 +0% -0% 55 +0% -0% 0%

site-editor

Metric 5293336 trunk % Change
serverResponse 319.77 ms +4.77% -7.55% 329.31 ms +1.27% -8.18% -2.9%
firstPaint 356.1 ms +5.71% -11.08% 307.19 ms +26.58% -3.02% 15.92%
domContentLoaded 682.58 ms +2.19% -1.94% 688.17 ms +0.7% -1.36% -0.81%
loaded 683.97 ms +2.16% -1.96% 689.51 ms +0.7% -1.35% -0.8%
firstContentfulPaint 377.94 ms +2.2% -0.5% 380.38 ms +2.55% -2.72% -0.64%
firstBlock 2098.12 ms +1.77% -2.07% 2153.05 ms +0.93% -0.76% -2.55%
type 16.22 ms +9.31% -4.19% 19.21 ms +13.64% -10.93% -15.56%
navigate 91.63 ms +2.76% -1% 92.67 ms +4.04% -1.46% -1.12%
loadPatterns 1200.85 ms +11.52% -3.67% 1380.65 ms +2.37% -15.31% -13.02%
loadPages 995.52 ms +6.48% -3.83% 964.09 ms +6.27% -2.16% 3.26%
wpTotal 311.44 ms +4.88% -7.75% 320.96 ms +1.24% -8.43% -2.97%
wpMemoryUsage 12.84 MB +0% -0% 12.80 MB +0% -0% 0.28%
wpDbQueries 45 +0% -0% 45 +0% -0% 0%

a75a30c 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.

As a user I want to be able to add multiple close buttons so that users can close the overlay from different positions in /test/e2e/specs/site-editor/navigation-overlay-template-part.spec.js, passed after 1 failed attempt.
Error: expect(locator).toHaveCount(expected) failed

Locator:  getByRole('button', { name: 'Close' })
Expected: 2
Received: 1
Timeout:  5000ms

Call log:
  - Expect "toHaveCount" getByRole('button', { name: 'Close' }) with timeout 5000ms
  - waiting for getByRole('button', { name: 'Close' })
    14 × locator resolved to 1 element
       - unexpected value "1"

    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/site-editor/navigation-overlay-template-part.spec.js:228:33

a75a30c Run

@t-hamano t-hamano self-assigned this Nov 29, 2026
@github-actions github-actions Bot added the [Package] Edit Widgets /packages/edit-widgets label Nov 29, 2026
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011g9URxg61iAc4ZxQiqFamu
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011g9URxg61iAc4ZxQiqFamu
@t-hamano
t-hamano marked this pull request as ready for review December 1, 2026 09:24
@github-actions
github-actions Bot requested review from aduth and ciampo December 1, 2026 09:24
@t-hamano
t-hamano requested review from a team and Mamaduka December 1, 2026 10:55

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

Thanks! Every item from the old menus is still there and works the same, so this looks close. Two inline comments, plus a few nits:

  • packages/base-styles/_z-index.scss:104: .components-popover.more-menu__content has no users left after this PR. It could be removed here or in a follow-up, with a base-styles CHANGELOG note.
  • The two more-menu-preference-item.tsx files differ only in SCOPE. Some duplication is unavoidable since Menu context doesn't cross bundles, but the checked state, toggle and announcement could live in a private @wordpress/preferences hook later. Fine as a follow-up.
  • Optional: the edit-widgets CHANGELOG lists the slot removal under "Enhancements". Since the slot was never exported, the clause could also just be dropped.

@github-actions github-actions Bot added the [Package] Base styles /packages/base-styles label Dec 2, 2026
@t-hamano

t-hamano commented Dec 2, 2026

Copy link
Copy Markdown
Contributor Author

@ciampo, thanks for the review!

  • packages/base-styles/_z-index.scss:104: .components-popover.more-menu__content has no users left after this PR. It could be removed here or in a follow-up, with a base-styles CHANGELOG note.
  • Optional: the edit-widgets CHANGELOG lists the slot removal under "Enhancements". Since the slot was never exported, the clause could also just be dropped.

Fixed in 22aff48 and 25b2907

  • The two more-menu-preference-item.tsx files differ only in SCOPE. Some duplication is unavoidable since Menu context doesn't cross bundles, but the checked state, toggle and announcement could live in a private @wordpress/preferences hook later. Fine as a follow-up.

Since similar code exists not only in the widgets and Customizer but also in the editor, we should be able to eliminate the duplication across all three. I would like to address this in a follow-up.

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

Happy to help review the follow-up when you get to it :)

@t-hamano
t-hamano merged commit bcb02ee into trunk Dec 3, 2026
87 checks passed
@t-hamano
t-hamano deleted the update/widgets-options-menu-ui-menu branch December 3, 2026 08:06
@github-actions github-actions Bot added this to the Gutenberg 24.7 milestone Dec 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Feature] Widgets Customizer Ability to add and edit blocks in Customize → Widgets. [Feature] Widgets Screen The block-based screen that replaced widgets.php. [Package] Base styles /packages/base-styles [Package] Edit Widgets /packages/edit-widgets [Type] Enhancement A suggestion for improvement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Widgets: Migrate the Options menu to Menu from @wordpress/ui

4 participants