diff --git a/packages/customize-widgets/CHANGELOG.md b/packages/customize-widgets/CHANGELOG.md index 51dc911ce80755..e40bee2f851d44 100644 --- a/packages/customize-widgets/CHANGELOG.md +++ b/packages/customize-widgets/CHANGELOG.md @@ -4,6 +4,7 @@ ### Bug Fixes +- 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/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..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 @@ -70,6 +70,11 @@ 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(); 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' } ) + .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 @@ -721,9 +721,9 @@ test.describe( 'Widgets Customizer', () => { const inserterToggle = documentTools.getByRole( 'button', { name: 'Add block', } ); - const optionsToggle = documentTools.getByRole( 'button', { - name: 'Options', - } ); + const optionsToggle = page + .locator( '.customize-widgets-header' ) + .getByRole( 'button', { name: 'Options', exact: true } ); await undoButton.focus(); await expect( undoButton ).toBeFocused(); @@ -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 ( {