From 75654205313eb666a6c0ecab4eef95c4c05f54f2 Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 27 Nov 2026 02:24:15 +0000 Subject: [PATCH 1/6] Customize Widgets: Move the Options menu out of the document tools toolbar The Options menu was rendered inside the `NavigableToolbar`, so it picked up the `toolbar` variant through the components context system and its popover used the black block toolbar styles. Render it after the toolbar, like the widgets editor and the post editor, and use a plain `DropdownMenu`. Co-authored-by: t-hamano <54422211+t-hamano@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_011g9URxg61iAc4ZxQiqFamu --- .../src/components/header/index.jsx | 2 +- .../src/components/header/style.scss | 19 +++++++++++-------- .../header/test/index.jsdom.test.tsx | 10 ++++++++++ .../src/components/more-menu/index.jsx | 10 +++------- .../specs/widgets/customizing-widgets.spec.js | 14 +++++++------- 5 files changed, 32 insertions(+), 23 deletions(-) diff --git a/packages/customize-widgets/src/components/header/index.jsx b/packages/customize-widgets/src/components/header/index.jsx index 3289351e1a4dae..490b014fbffbf7 100644 --- a/packages/customize-widgets/src/components/header/index.jsx +++ b/packages/customize-widgets/src/components/header/index.jsx @@ -85,8 +85,8 @@ function Header( { } } size="compact" /> - + { createPortal( diff --git a/packages/customize-widgets/src/components/header/style.scss b/packages/customize-widgets/src/components/header/style.scss index 32ce9a40441526..70f3c9d5fcefd0 100644 --- a/packages/customize-widgets/src/components/header/style.scss +++ b/packages/customize-widgets/src/components/header/style.scss @@ -15,7 +15,11 @@ } display: flex; - justify-content: flex-end; + align-items: center; + gap: $grid-unit-10; + // Keep the focus ring of the options menu toggle within the customizer + // sidebar, which clips its overflow. + padding-inline-end: $grid-unit-15; // Offset the customizer's sidebar padding. // Zero bottom margin so that the fixed toolbar is right under the header. @@ -29,20 +33,19 @@ .customize-widgets-header-toolbar { display: flex; + flex: 1; border: none; - width: 100%; align-items: center; gap: $grid-unit-10; - // Keep the outset focus ring of the first and last buttons within the - // customizer sidebar, which clips its overflow. - padding: 0 $grid-unit-15; + // Keep the outset focus ring of the first button within the customizer + // sidebar, which clips its overflow. + padding-inline-start: $grid-unit-15; // The Toolbar component adds different styles to buttons, so we reset them // here to the original button styles, consistent with the document tools // of the other editors. // Specificity bump needed to offset https://github.com/WordPress/gutenberg/blob/8ea29cb04412c80c9adf7c1db0e816d6a0ac1232/packages/components/src/toolbar/style.scss#L76 - > .components-button.has-icon.has-icon.has-icon, - > .components-dropdown > .components-button.has-icon.has-icon { + > .components-button.has-icon.has-icon.has-icon { height: $button-size-compact; min-width: $button-size-compact; padding: 4px; @@ -75,7 +78,7 @@ .customize-widgets-header-toolbar__inserter-toggle.components-button.has-icon { border-radius: $radius-small; - // Push the inserter toggle and the buttons after it to the end. + // Push the inserter toggle to the end. margin: $grid-unit-15 0 $grid-unit-15 auto; svg { diff --git a/packages/customize-widgets/src/components/header/test/index.jsdom.test.tsx b/packages/customize-widgets/src/components/header/test/index.jsdom.test.tsx index 17aa830ce78afb..95349cbcb704ac 100644 --- a/packages/customize-widgets/src/components/header/test/index.jsdom.test.tsx +++ b/packages/customize-widgets/src/components/header/test/index.jsdom.test.tsx @@ -70,9 +70,19 @@ describe( 'Header', () => { screen.getByRole( 'button', { name: 'Add block' } ) ).toHaveFocus(); await user.keyboard( '{ArrowRight}' ); + expect( undoButton ).toHaveFocus(); + + // The options menu toggle is outside the toolbar, and is the next + // tab stop. + await user.tab(); expect( screen.getByRole( 'button', { name: 'Options' } ) ).toHaveFocus(); + expect( + screen.getByRole( 'toolbar', { name: 'Document tools' } ) + ).not.toContainElement( + screen.getByRole( 'button', { name: 'Options' } ) + ); } ); it( 'undoes and redoes changes when there is history', async () => { diff --git a/packages/customize-widgets/src/components/more-menu/index.jsx b/packages/customize-widgets/src/components/more-menu/index.jsx index 2881e1856a41b2..8fd3706eef8142 100644 --- a/packages/customize-widgets/src/components/more-menu/index.jsx +++ b/packages/customize-widgets/src/components/more-menu/index.jsx @@ -1,8 +1,4 @@ -import { - MenuGroup, - MenuItem, - ToolbarDropdownMenu, -} from '@wordpress/components'; +import { DropdownMenu, MenuGroup, MenuItem } from '@wordpress/components'; import { useDispatch } from '@wordpress/data'; import { useState } from '@wordpress/element'; import { __, _x } from '@wordpress/i18n'; @@ -33,7 +29,7 @@ export default function MoreMenu() { return ( <> - ) } - + { await expect( welcomeGuideHeading ).toBeHidden(); await page - .getByRole( 'toolbar', { name: 'Document tools' } ) .getByRole( 'button', { name: 'Options', exact: true } ) .click(); // The welcome guide is not a preference, so the item is a plain menu @@ -721,8 +720,9 @@ test.describe( 'Widgets Customizer', () => { const inserterToggle = documentTools.getByRole( 'button', { name: 'Add block', } ); - const optionsToggle = documentTools.getByRole( 'button', { + const optionsToggle = page.getByRole( 'button', { name: 'Options', + exact: true, } ); await undoButton.focus(); @@ -735,19 +735,19 @@ test.describe( 'Widgets Customizer', () => { await page.keyboard.press( 'ArrowRight' ); await expect( inserterToggle ).toBeFocused(); await page.keyboard.press( 'ArrowRight' ); - await expect( optionsToggle ).toBeFocused(); - await page.keyboard.press( 'ArrowRight' ); await expect( undoButton ).toBeFocused(); await page.keyboard.press( 'ArrowLeft' ); - await expect( optionsToggle ).toBeFocused(); + await expect( inserterToggle ).toBeFocused(); await page.keyboard.press( 'Home' ); await expect( undoButton ).toBeFocused(); await page.keyboard.press( 'End' ); - await expect( optionsToggle ).toBeFocused(); + await expect( inserterToggle ).toBeFocused(); - // The toolbar is a single tab stop. + // The toolbar is a single tab stop, followed by the options menu + // toggle, like in the other editors. await page.keyboard.press( 'Tab' ); await expect( documentTools.locator( ':focus' ) ).toHaveCount( 0 ); + await expect( optionsToggle ).toBeFocused(); } ); test( 'should undo and redo changes from the document tools', async ( { From 8627a491015e9e3bd8c2cea8a6f148d1fe98fb3e Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 27 Nov 2026 02:24:52 +0000 Subject: [PATCH 2/6] Add changelog entry Co-authored-by: t-hamano <54422211+t-hamano@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_011g9URxg61iAc4ZxQiqFamu --- packages/customize-widgets/CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/customize-widgets/CHANGELOG.md b/packages/customize-widgets/CHANGELOG.md index 51dc911ce80755..45ee657966a5cf 100644 --- a/packages/customize-widgets/CHANGELOG.md +++ b/packages/customize-widgets/CHANGELOG.md @@ -4,6 +4,7 @@ ### Bug Fixes +- Move the Options menu out of the document tools toolbar, so its popover matches the other editors ([#87504](https://github.com/WordPress/gutenberg/pull/87504)). - Keep the widget inserter open when Escape is pressed during IME composition ([#87353](https://github.com/WordPress/gutenberg/pull/87353)). - Use `Highlight` and `HighlightText` for the pressed header buttons in forced colors mode, so they follow the active contrast theme in Chromium ([#87010](https://github.com/WordPress/gutenberg/pull/87010)). From 932ab40fb352312eceae4403c348991ff3cfd096 Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 27 Nov 2026 11:13:03 +0000 Subject: [PATCH 3/6] Remove redundant assertion Co-authored-by: t-hamano <54422211+t-hamano@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_011g9URxg61iAc4ZxQiqFamu --- .../src/components/header/test/index.jsdom.test.tsx | 5 ----- 1 file changed, 5 deletions(-) diff --git a/packages/customize-widgets/src/components/header/test/index.jsdom.test.tsx b/packages/customize-widgets/src/components/header/test/index.jsdom.test.tsx index 95349cbcb704ac..713215dfeb3fad 100644 --- a/packages/customize-widgets/src/components/header/test/index.jsdom.test.tsx +++ b/packages/customize-widgets/src/components/header/test/index.jsdom.test.tsx @@ -78,11 +78,6 @@ describe( 'Header', () => { expect( screen.getByRole( 'button', { name: 'Options' } ) ).toHaveFocus(); - expect( - screen.getByRole( 'toolbar', { name: 'Document tools' } ) - ).not.toContainElement( - screen.getByRole( 'button', { name: 'Options' } ) - ); } ); it( 'undoes and redoes changes when there is history', async () => { From b0bbf93d929c8500c18889bedd4d44a27b9bdad9 Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 27 Nov 2026 11:29:04 +0000 Subject: [PATCH 4/6] Remove the side gaps around the fixed block toolbar Co-authored-by: t-hamano <54422211+t-hamano@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_011g9URxg61iAc4ZxQiqFamu --- packages/customize-widgets/CHANGELOG.md | 2 +- .../src/components/sidebar-block-editor/style.scss | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/packages/customize-widgets/CHANGELOG.md b/packages/customize-widgets/CHANGELOG.md index 45ee657966a5cf..e40bee2f851d44 100644 --- a/packages/customize-widgets/CHANGELOG.md +++ b/packages/customize-widgets/CHANGELOG.md @@ -4,7 +4,7 @@ ### Bug Fixes -- Move the Options menu out of the document tools toolbar, so its popover matches the other editors ([#87504](https://github.com/WordPress/gutenberg/pull/87504)). +- Polish the header: move the Options menu out of the document tools toolbar so its popover matches the other editors, and remove the side gaps around the fixed block toolbar ([#87504](https://github.com/WordPress/gutenberg/pull/87504)). - Keep the widget inserter open when Escape is pressed during IME composition ([#87353](https://github.com/WordPress/gutenberg/pull/87353)). - Use `Highlight` and `HighlightText` for the pressed header buttons in forced colors mode, so they follow the active contrast theme in Chromium ([#87010](https://github.com/WordPress/gutenberg/pull/87010)). diff --git a/packages/customize-widgets/src/components/sidebar-block-editor/style.scss b/packages/customize-widgets/src/components/sidebar-block-editor/style.scss index bf1a444f113b7f..3a7fe2aee0e6da 100644 --- a/packages/customize-widgets/src/components/sidebar-block-editor/style.scss +++ b/packages/customize-widgets/src/components/sidebar-block-editor/style.scss @@ -1,5 +1,14 @@ +@use "@wordpress/base-styles/variables" as *; @use "@wordpress/base-styles/z-index" as *; +// The fixed block toolbar, rendered right after the header in top toolbar mode +// and on small screens. +.customize-widgets-header + .block-editor-block-contextual-toolbar { + // Offset the customizer's sidebar padding, like the header. + margin-inline: -$grid-unit-15; + width: calc(100% + #{ $grid-unit-30 }); +} + // stylelint-disable selector-class-pattern -- WordPress Customizer control class names use underscores by convention. .customize-control-sidebar_block_editor .block-editor-block-list__block-popover { // FloatingUI library used in Popover component forces us to have an "absolute" inline style. From 078d4f7c4410019bff0356195d438cd9da6255f2 Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 29 Nov 2026 10:58:17 +0000 Subject: [PATCH 5/6] Use width: auto for the fixed block toolbar offset Co-authored-by: t-hamano <54422211+t-hamano@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_011g9URxg61iAc4ZxQiqFamu --- .../src/components/sidebar-block-editor/style.scss | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/customize-widgets/src/components/sidebar-block-editor/style.scss b/packages/customize-widgets/src/components/sidebar-block-editor/style.scss index 3a7fe2aee0e6da..f1b6c0b8a87e42 100644 --- a/packages/customize-widgets/src/components/sidebar-block-editor/style.scss +++ b/packages/customize-widgets/src/components/sidebar-block-editor/style.scss @@ -6,7 +6,7 @@ .customize-widgets-header + .block-editor-block-contextual-toolbar { // Offset the customizer's sidebar padding, like the header. margin-inline: -$grid-unit-15; - width: calc(100% + #{ $grid-unit-30 }); + width: auto; } // stylelint-disable selector-class-pattern -- WordPress Customizer control class names use underscores by convention. From 56030ae2bca5d83bb8092da3e7f46f88ec65d7b2 Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 29 Nov 2026 11:03:26 +0000 Subject: [PATCH 6/6] Scope the Options toggle locators to the header Co-authored-by: t-hamano <54422211+t-hamano@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_011g9URxg61iAc4ZxQiqFamu --- test/e2e/specs/widgets/customizing-widgets.spec.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/e2e/specs/widgets/customizing-widgets.spec.js b/test/e2e/specs/widgets/customizing-widgets.spec.js index ce5ded7dd6fe32..8db0211a41cf97 100644 --- a/test/e2e/specs/widgets/customizing-widgets.spec.js +++ b/test/e2e/specs/widgets/customizing-widgets.spec.js @@ -661,6 +661,7 @@ test.describe( 'Widgets Customizer', () => { await expect( welcomeGuideHeading ).toBeHidden(); await page + .locator( '.customize-widgets-header' ) .getByRole( 'button', { name: 'Options', exact: true } ) .click(); // The welcome guide is not a preference, so the item is a plain menu @@ -720,10 +721,9 @@ test.describe( 'Widgets Customizer', () => { const inserterToggle = documentTools.getByRole( 'button', { name: 'Add block', } ); - const optionsToggle = page.getByRole( 'button', { - name: 'Options', - exact: true, - } ); + const optionsToggle = page + .locator( '.customize-widgets-header' ) + .getByRole( 'button', { name: 'Options', exact: true } ); await undoButton.focus(); await expect( undoButton ).toBeFocused();