Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/customize-widgets/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)).

Expand Down
2 changes: 1 addition & 1 deletion packages/customize-widgets/src/components/header/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@ function Header( {
} }
size="compact"
/>
<MoreMenu />
</NavigableToolbar>
<MoreMenu />
</div>

{ createPortal(
Expand Down
19 changes: 11 additions & 8 deletions packages/customize-widgets/src/components/header/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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;
Expand Down Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
10 changes: 3 additions & 7 deletions packages/customize-widgets/src/components/more-menu/index.jsx
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -33,7 +29,7 @@ export default function MoreMenu() {

return (
<>
<ToolbarDropdownMenu
<DropdownMenu
icon={ moreVertical }
label={ __( 'Options' ) }
popoverProps={ {
Expand Down Expand Up @@ -119,7 +115,7 @@ export default function MoreMenu() {
</MenuGroup>
</>
) }
</ToolbarDropdownMenu>
</DropdownMenu>
<KeyboardShortcutHelpModal
isModalActive={ isKeyboardShortcutsModalActive }
toggleModal={ toggleKeyboardShortcutsModal }
Expand Down
Original file line number Diff line number Diff line change
@@ -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: auto;
}

// 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.
Expand Down
18 changes: 9 additions & 9 deletions test/e2e/specs/widgets/customizing-widgets.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -661,7 +661,7 @@ test.describe( 'Widgets Customizer', () => {
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
Expand Down Expand Up @@ -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();
Expand All @@ -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 ( {
Expand Down
Loading