Skip to content
Open
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/block-editor/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

### Bug Fixes

- Keep toolbar menus open when their portals add focus guards ([#82967](https://github.com/WordPress/gutenberg/pull/82967)).
- Fix the translator comments for the "blocks moved" and "blocks added" screen reader messages, which described the count as a block name ([#83555](https://github.com/WordPress/gutenberg/pull/83555)).
- `BlockCompare`: Show whitespace differences in the Resolve Block dialog. The markup's spaces and blank lines are kept instead of collapsed by the browser, and each added or removed line break gets a visible marker, so a diff made only of whitespace no longer looks identical on both sides. The dialog also shows the markup of a converted Custom HTML block, which is kept in its `innerContent` rather than produced by `save`, instead of an empty diff ([#82397](https://github.com/WordPress/gutenberg/pull/82397)).

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,13 @@ function useIsAccessibleToolbar( toolbarRef ) {
);

const determineIsAccessibleToolbar = useCallback( () => {
const tabbables = focus.tabbable.find( toolbarRef.current );
// Portaled menus add focus guards beside their trigger. These are not controls.
const tabbables = focus.tabbable
.find( toolbarRef.current )
.filter(
( element ) =>
! element.hasAttribute( 'data-base-ui-focus-guard' )
);
// A hidden toolbar has no tabbables, so keep its current classification.
if ( tabbables.length === 0 ) {
return;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import { describe, expect, it } from 'vitest';
import { act, screen, waitFor } from '@testing-library/react';
import { render } from 'vitest-browser-react';
import { userEvent } from 'vitest/browser';
import { ToolbarItem } from '@wordpress/components';
// eslint-disable-next-line @wordpress/use-recommended-components -- Intentional early adoption of the new Menu, pending WordPress/gutenberg#76135.
import { Menu } from '@wordpress/ui';
import { createElement } from '@wordpress/element';
import NavigableToolbar from '..';

Expand All @@ -20,6 +24,38 @@ function createToolbar( { hidden = false, extraChildren = 0 } = {} ) {
}

describe( 'NavigableToolbar', () => {
it( 'keeps a portaled menu open without remounting the toolbar', async () => {
await render(
createElement(
NavigableToolbar,
{ 'aria-label': 'Block tools' },
createElement(
Menu.Root,
null,
createElement( ToolbarItem, null, ( props ) =>
createElement( Menu.Trigger, props, 'Actions' )
),
createElement(
Menu.Popup,
null,
createElement(
Menu.Item,
null,
createElement( Menu.ItemLabel, null, 'Move' )
)
)
)
)
);
const toolbar = screen.getByRole( 'toolbar' );
const trigger = screen.getByRole( 'button', { name: 'Actions' } );
await userEvent.click( trigger );
await expect.element( screen.getByRole( 'menu' ) ).toBeVisible();
expect( screen.getByRole( 'toolbar' ) ).toBe( toolbar );
await userEvent.keyboard( '{Escape}' );
await expect.element( trigger ).toHaveFocus();
} );

it( 'does not reclassify a visibility-hidden toolbar when its subtree changes', async () => {
const { rerender } = await render( createToolbar() );
const initialToolbar = screen.getByRole( 'toolbar' );
Expand Down
4 changes: 4 additions & 0 deletions packages/customize-widgets/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@

- Error boundary: Explicitly announce the error title and description, excluding action labels ([#82737](https://github.com/WordPress/gutenberg/pull/82737)).

### Internal

- Use `@wordpress/ui` for the Options menu ([#82967](https://github.com/WordPress/gutenberg/pull/82967)).

## 5.56.0 (2026-09-23)

### Bug Fixes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export default function useClearSelectedBlock( sidebarControl, popoverRef ) {
// 3. It should also not exist in the container, the popover, nor the dialog.
! container.contains( element ) &&
! popoverRef.current.contains( element ) &&
! element.closest( '[data-wp-compat-overlay-slot]' ) &&
! element.closest( '[role="dialog"]' ) &&
// 4. The inspector should not be opened.
! inspector.expanded()
Expand Down
195 changes: 97 additions & 98 deletions packages/customize-widgets/src/components/more-menu/index.jsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,14 @@
import {
MenuGroup,
MenuItem,
ToolbarDropdownMenu,
} from '@wordpress/components';
import { Button, ToolbarItem } from '@wordpress/components';
import { useDispatch } from '@wordpress/data';
import { useState } from '@wordpress/element';
import { __, _x } from '@wordpress/i18n';
import { external, moreVertical } from '@wordpress/icons';
import { displayShortcut } from '@wordpress/keycodes';
import { moreVertical } from '@wordpress/icons';
import { keyboardShortcut } from '@wordpress/keycodes';
import { useShortcut } from '@wordpress/keyboard-shortcuts';
import {
PreferenceToggleMenuItem,
store as preferencesStore,
} from '@wordpress/preferences';
import { VisuallyHidden } from '@wordpress/ui';
import { store as preferencesStore } from '@wordpress/preferences';
// eslint-disable-next-line @wordpress/use-recommended-components -- Intentional early adoption of the new Menu, pending WordPress/gutenberg#76135.
import { Menu } from '@wordpress/ui';
import MoreMenuPreferenceItem from './more-menu-preference-item';
import KeyboardShortcutHelpModal from '../keyboard-shortcut-help-modal';

export default function MoreMenu() {
Expand All @@ -33,94 +28,98 @@ export default function MoreMenu() {

return (
<>
<ToolbarDropdownMenu
icon={ moreVertical }
label={ __( 'Options' ) }
popoverProps={ {
placement: 'bottom-end',
className: 'more-menu-dropdown__content',
} }
toggleProps={ {
tooltipPosition: 'bottom',
size: 'compact',
} }
>
{ () => (
<>
<MenuGroup label={ _x( 'View', 'noun' ) }>
<PreferenceToggleMenuItem
scope="core/customize-widgets"
name="fixedToolbar"
label={ __( 'Top toolbar' ) }
info={ __(
'Access all block and document tools in a single place'
) }
messageActivated={ __(
'Top toolbar activated'
) }
messageDeactivated={ __(
'Top toolbar deactivated'
) }
/>
</MenuGroup>
<MenuGroup label={ __( 'Tools' ) }>
<MenuItem
onClick={ () => {
setIsKeyboardShortcutsModalVisible( true );
} }
shortcut={ displayShortcut.access( 'h' ) }
>
<Menu.Root modal={ false }>
<ToolbarItem>
{ ( toggleProps ) => (
<Menu.Trigger
render={
<Button
{ ...toggleProps }
size="compact"
icon={ moreVertical }
label={ __( 'Options' ) }
showTooltip
tooltipPosition="bottom"
/>
}
/>
) }
</ToolbarItem>
<Menu.Popup positioner={ <Menu.Positioner align="end" /> }>
<Menu.Group>
<Menu.GroupLabel>
{ _x( 'View', 'noun' ) }
</Menu.GroupLabel>
<MoreMenuPreferenceItem
scope="core/customize-widgets"
name="fixedToolbar"
label={ __( 'Top toolbar' ) }
info={ __(
'Access all block and document tools in a single place'
) }
messageActivated={ __( 'Top toolbar activated' ) }
messageDeactivated={ __(
'Top toolbar deactivated'
) }
/>
</Menu.Group>
<Menu.Separator />
<Menu.Group>
<Menu.GroupLabel>{ __( 'Tools' ) }</Menu.GroupLabel>
<Menu.Item
onClick={ () => {
setIsKeyboardShortcutsModalVisible( true );
} }
shortcut={ keyboardShortcut.access( 'h' ) }
>
<Menu.ItemLabel>
{ __( 'Keyboard shortcuts' ) }
</MenuItem>
<MenuItem
onClick={ () =>
toggle(
'core/customize-widgets',
'welcomeGuide'
)
}
>
</Menu.ItemLabel>
</Menu.Item>
<Menu.Item
onClick={ () =>
toggle(
'core/customize-widgets',
'welcomeGuide'
)
}
>
<Menu.ItemLabel>
{ __( 'Welcome Guide' ) }
</MenuItem>
<MenuItem
role="menuitem"
icon={ external }
href={ __(
'https://wordpress.org/documentation/article/block-based-widgets-editor/'
) }
target="_blank"
rel="noopener"
>
{ __( 'Help' ) }
<VisuallyHidden render={ <span /> }>
{
/* translators: accessibility text */
__( '(opens in a new tab)' )
}
</VisuallyHidden>
</MenuItem>
</MenuGroup>
<MenuGroup label={ __( 'Preferences' ) }>
<PreferenceToggleMenuItem
scope="core/customize-widgets"
name="keepCaretInsideBlock"
label={ __(
'Contain text cursor inside block'
) }
info={ __(
'Aids screen readers by stopping text caret from leaving blocks.'
) }
messageActivated={ __(
'Contain text cursor inside block activated'
) }
messageDeactivated={ __(
'Contain text cursor inside block deactivated'
) }
/>
</MenuGroup>
</>
) }
</ToolbarDropdownMenu>
</Menu.ItemLabel>
</Menu.Item>
<Menu.LinkItem
href={ __(
'https://wordpress.org/documentation/article/block-based-widgets-editor/'
) }
openInNewTab
rel="noopener"
>
<Menu.ItemLabel>{ __( 'Help' ) }</Menu.ItemLabel>
</Menu.LinkItem>
</Menu.Group>
<Menu.Separator />
<Menu.Group>
<Menu.GroupLabel>
{ __( 'Preferences' ) }
</Menu.GroupLabel>
<MoreMenuPreferenceItem
scope="core/customize-widgets"
name="keepCaretInsideBlock"
label={ __( 'Contain text cursor inside block' ) }
info={ __(
'Aids screen readers by stopping text caret from leaving blocks.'
) }
messageActivated={ __(
'Contain text cursor inside block activated'
) }
messageDeactivated={ __(
'Contain text cursor inside block deactivated'
) }
/>
</Menu.Group>
</Menu.Popup>
</Menu.Root>
<KeyboardShortcutHelpModal
isModalActive={ isKeyboardShortcutsModalActive }
toggleModal={ toggleKeyboardShortcutsModal }
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
import { speak } from '@wordpress/a11y';
import { useDispatch, useSelect } from '@wordpress/data';
import { __, sprintf } from '@wordpress/i18n';
import { store as preferencesStore } from '@wordpress/preferences';
// eslint-disable-next-line @wordpress/use-recommended-components -- Intentional early adoption of the new Menu, pending WordPress/gutenberg#76135.
import { Menu } from '@wordpress/ui';

type MoreMenuPreferenceItemProps = {
scope: string;
name: string;
label: string;
info?: string;
messageActivated?: string;
messageDeactivated?: string;
};

// Menu parts must come from the same package bundle to share their context.
export default function MoreMenuPreferenceItem( {
scope,
name,
label,
info,
messageActivated,
messageDeactivated,
}: MoreMenuPreferenceItemProps ) {
const isActive = useSelect(
( select ) => !! select( preferencesStore ).get( scope, name ),
[ scope, name ]
);
const { toggle } = useDispatch( preferencesStore );

return (
<Menu.CheckboxItem
checked={ isActive }
onCheckedChange={ () => {
toggle( scope, name );
speak(
isActive
? messageDeactivated ||
sprintf(
/* translators: %s: preference name, e.g. 'Fullscreen mode' */
__( 'Preference deactivated - %s' ),
label
)
: messageActivated ||
sprintf(
/* translators: %s: preference name, e.g. 'Fullscreen mode' */
__( 'Preference activated - %s' ),
label
)
);
} }
>
<Menu.ItemLabel>{ label }</Menu.ItemLabel>
{ info ? (
<Menu.ItemDescription>{ info }</Menu.ItemDescription>
) : null }
</Menu.CheckboxItem>
);
}

This file was deleted.

1 change: 0 additions & 1 deletion packages/customize-widgets/src/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
@use "./components/header/style.scss" as *;
@use "./components/inserter/style.scss" as *;
@use "./components/keyboard-shortcut-help-modal/style.scss" as *;
@use "./components/more-menu/style.scss" as *;
@use "./components/sidebar-block-editor/style.scss" as *;
@use "./components/welcome-guide/style.scss" as *;
@use "./controls/style.scss" as *;
Expand Down
4 changes: 4 additions & 0 deletions packages/edit-widgets/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@

- Error boundary: Explicitly announce the error title and description, excluding action labels ([#82737](https://github.com/WordPress/gutenberg/pull/82737)).

### Internal

- Use `@wordpress/ui` for the Options menu while preserving legacy Tools fills ([#82967](https://github.com/WordPress/gutenberg/pull/82967)).

## 6.56.0 (2026-09-23)

### Bug Fixes
Expand Down
Loading
Loading