Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
a07adff
DataViews: Name the action in selection checkbox labels
HrithikDalal Nov 2, 2026
c03f036
DataViews: Announce when bulk actions become available or unavailable
HrithikDalal Nov 2, 2026
ceb80d8
DataViews: Keep focus in the layout when the focused control is removed
HrithikDalal Nov 2, 2026
156d6c7
DataViews: Mark the triggers of actions that open a dialog
HrithikDalal Nov 2, 2026
9e29f1f
Fields: Hide decorative author avatars from assistive technologies
HrithikDalal Nov 2, 2026
f39ae01
Boot: Only announce the route title when the path changes
HrithikDalal Nov 2, 2026
d834029
DataViews: Replace the Cancel icon of the bulk actions with a Clear s…
HrithikDalal Nov 2, 2026
33f27d9
DataViews: Keep the table media out of the tab order next to a clicka…
HrithikDalal Nov 2, 2026
21b103a
DataViews: Set the grid selection checkbox apart from the preview
HrithikDalal Nov 2, 2026
ef0da6a
Media Utils: Show that clicking the media preview replaces it
HrithikDalal Nov 2, 2026
488065a
DataViews: Name list items by their title only
HrithikDalal Nov 2, 2026
d0b09a7
Add changelog entries
HrithikDalal Nov 2, 2026
ce9b9d1
Boot: Declare the test dependencies
HrithikDalal Nov 2, 2026
23c865e
Add the PR number to the changelog entries
HrithikDalal Nov 2, 2026
702c1b4
DataViews: Only announce bulk actions in the layouts that show them
HrithikDalal Nov 2, 2026
8384e30
DataViews: Don't bring focus back after the user moved it away
HrithikDalal Nov 2, 2026
c47d7e7
DataViews: Use an outline for the focus ring of the table media
HrithikDalal Nov 2, 2026
9a10e19
DataViews: Recover focus after an emptied page, a removed focused ite…
HrithikDalal Nov 2, 2026
d9abd3e
DataViews: Name list items by their content when the title is hidden
HrithikDalal Nov 2, 2026
521670b
DataViews: Check the loaded items for bulk actions with infinite scroll
HrithikDalal Nov 2, 2026
b51674c
DataViews: Let popovers, modals and loading settle before recovering …
HrithikDalal Nov 2, 2026
f95a1f1
Tests: Find list items by their button and cover focus after a bulk t…
HrithikDalal Nov 2, 2026
70e981f
DataViews: Forget the focused item once focus moves on, and fall back…
HrithikDalal Nov 2, 2026
6cbc680
DataViews: Track focus across the page in the focus fallback
HrithikDalal Nov 2, 2026
4ee7bad
DataViews: Only skip focus recovery for items infinite scroll unloads…
HrithikDalal Nov 2, 2026
34160bc
DataViews: Skip disabled and hidden controls when moving focus on
HrithikDalal Nov 2, 2026
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
4 changes: 4 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions packages/boot/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

### Bug Fixes

- Only announce the route title when the path changes, so it no longer cuts off notices, such as the one confirming that an item was moved to the trash ([#86150](https://github.com/WordPress/gutenberg/pull/86150)).
- Generated CSS module class names now change whenever their CSS changes, so they differ from earlier versions. Two versions of the package loaded on the same page, such as one in WordPress Core and an older copy bundled in a plugin, no longer apply their styles to each other's elements ([#85900](https://github.com/WordPress/gutenberg/pull/85900)).

## 0.25.0 (2026-10-20)
Expand Down
4 changes: 4 additions & 0 deletions packages/boot/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@
"@wordpress/url": "file:../url",
"clsx": "^2.1.1"
},
"devDependencies": {
"@testing-library/react": "^16.3.3",
"vitest": "^5.0.3"
},
"peerDependencies": {
"@types/react": "^18 || ^19",
"react": "^18 || ^19",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import { renderHook } from '@testing-library/react';
import { beforeEach, describe, expect, it, vi } from 'vitest';
import { speak } from '@wordpress/a11y';
import useRouteTitle from '../use-route-title';

let location: { pathname: string; search: Record< string, unknown > };

vi.mock( import( '@wordpress/a11y' ), () => ( { speak: vi.fn() } ) as any );
vi.mock( import( '@wordpress/data' ), async ( importOriginal ) => ( {
...( await importOriginal() ),
useSelect: ( () => 'My Site' ) as any,
} ) );
vi.mock(
import( '../../../lock-unlock' ),
() =>
( {
unlock: () => ( {
useLocation: () => location,
useMatches: () => [ { loaderData: { title: 'Pages' } } ],
} ),
} ) as any
);

describe( 'useRouteTitle', () => {
beforeEach( () => {
vi.mocked( speak ).mockClear();
location = { pathname: '/types/page/list/all', search: {} };
} );

it( 'announces the title when the path changes', () => {
const { rerender } = renderHook( () => useRouteTitle() );
vi.mocked( speak ).mockClear();
location = { ...location, pathname: '/types/page/list/draft' };
rerender();
expect( speak ).toHaveBeenCalledWith( 'Pages', 'assertive' );
} );

it( 'does not announce the title when only the search changes', () => {
const { rerender } = renderHook( () => useRouteTitle() );
vi.mocked( speak ).mockClear();
location = { ...location, search: { postIds: [ '1' ] } };
rerender();
expect( speak ).not.toHaveBeenCalled();
} );
} );
10 changes: 7 additions & 3 deletions packages/boot/src/components/app/use-route-title.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@ const { useLocation, useMatches } = unlock( routePrivateApis );
* This hook should be called from the Root component to ensure it runs on every route.
*/
export default function useRouteTitle() {
const location = useLocation();
// Only a new path is a new screen. Search parameters also change while the
// screen stays, e.g. when the selection changes or an item is moved to the
// trash, and announcing the title then would clear the live regions and cut
// off the notice of what happened.
const { pathname } = useLocation();
const matches = useMatches();
const currentMatch = matches[ matches.length - 1 ];
const routeTitle = ( currentMatch?.loaderData as any )?.title as
Expand All @@ -35,7 +39,7 @@ export default function useRouteTitle() {

useEffect( () => {
isInitialLocationRef.current = false;
}, [ location ] );
}, [ pathname ] );

useEffect( () => {
// Don't update or announce the title for initial page load.
Expand Down Expand Up @@ -68,5 +72,5 @@ export default function useRouteTitle() {
speak( decodedRouteTitle, 'assertive' );
}
}
}, [ routeTitle, siteTitle, location ] );
}, [ routeTitle, siteTitle, pathname ] );
}
4 changes: 2 additions & 2 deletions packages/core-fields/src/attachment/author/view.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import clsx from 'clsx';
import { __ } from '@wordpress/i18n';
import { useState, useCallback, useEffect } from '@wordpress/element';
import { commentAuthorAvatar as authorIcon } from '@wordpress/icons';
import { Icon, Stack } from '@wordpress/ui';
Expand Down Expand Up @@ -52,7 +51,8 @@ export default function AuthorView( { item }: { item: MediaItem } ) {
<img
ref={ imgRef }
onLoad={ handleLoad }
alt={ __( 'Author avatar' ) }
// Decorative: the name of the author is next to it.
alt=""
src={ imageUrl }
/>
</div>
Expand Down
4 changes: 2 additions & 2 deletions packages/core-fields/src/post_type_supports/author/view.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import clsx from 'clsx';
import { __ } from '@wordpress/i18n';
import { useState } from '@wordpress/element';
import { commentAuthorAvatar as authorIcon } from '@wordpress/icons';
import { Icon, Stack } from '@wordpress/ui';
Expand Down Expand Up @@ -62,7 +61,8 @@ export default function AuthorView( { item }: { item: PostWithAuthor } ) {
>
<img
onLoad={ () => setIsImageLoaded( true ) }
alt={ __( 'Author avatar' ) }
// Decorative: the name of the author is next to it.
alt=""
src={ imageUrl }
/>
</div>
Expand Down
8 changes: 8 additions & 0 deletions packages/dataviews/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

### Enhancements

- Add `opensDialog` for actions whose `callback` opens a dialog. The triggers of these actions and of `RenderModal` actions now have `aria-haspopup="dialog"` ([#86150](https://github.com/WordPress/gutenberg/pull/86150)).
- Replace the close icon that cancels the selection with a "Clear selection" button next to the bulk actions ([#86150](https://github.com/WordPress/gutenberg/pull/86150)).
- DataForm: Tighten the line height of field values in the panel layout, so values that wrap onto several lines take less room ([#85828](https://github.com/WordPress/gutenberg/pull/85828)).
- Omit trailing ellipses from action button labels ([#85396](https://github.com/WordPress/gutenberg/pull/85396)).
- Render table bulk actions outside the table while preserving their placement over the column headers ([#85250](https://github.com/WordPress/gutenberg/pull/85250)).
Expand All @@ -19,6 +21,12 @@

### Bug Fixes

- Name the action in the labels of selection checkboxes: "Select [title]" ([#86150](https://github.com/WordPress/gutenberg/pull/86150)).
- Announce when selecting items makes bulk actions available and when clearing the selection removes them ([#86150](https://github.com/WordPress/gutenberg/pull/86150)).
- Move focus to the "Select all" checkbox, or the first control of the layout, when the focused control is removed, such as after moving an item to the trash ([#86150](https://github.com/WordPress/gutenberg/pull/86150)).
- Keep the table media out of the tab order and the accessibility tree when the title next to it leads to the same place, and show a focus ring on it otherwise ([#86150](https://github.com/WordPress/gutenberg/pull/86150)).
- Name list items by their title only, not by all of their content ([#86150](https://github.com/WordPress/gutenberg/pull/86150)).
- Set the grid selection checkbox apart from previews of any color ([#86150](https://github.com/WordPress/gutenberg/pull/86150)).
- DataForm: Keep the first line of a panel field label that wraps level with its value ([#85828](https://github.com/WordPress/gutenberg/pull/85828)).
- Replace the pagination page select with a page number input above 100 pages, so a dataset with tens of thousands of pages no longer freezes the browser ([#85303](https://github.com/WordPress/gutenberg/pull/85303)).

Expand Down
8 changes: 8 additions & 0 deletions packages/dataviews/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1177,6 +1177,14 @@ Function that performs the required action.
}
```

### `opensDialog`

Whether the `callback` opens a dialog, such as a modal. The trigger then has `aria-haspopup="dialog"`, as the triggers of `RenderModal` actions do.

- Type: `boolean`
- Optional
- Default: `false`

### `RenderModal`

Component to render UI in a modal for the action.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Button } from '@wordpress/components';
import { __ } from '@wordpress/i18n';
import { useMemo, useState, useContext } from '@wordpress/element';
import { useRegistry } from '@wordpress/data';
import { closeSmall, chevronDown } from '@wordpress/icons';
import { chevronDown } from '@wordpress/icons';
import { useViewportMatch } from '@wordpress/compose';
import {
Checkbox,
Expand All @@ -18,6 +18,7 @@ import type { SetSelection } from '../../types/private';
import type { ActionTriggerProps } from '../dataviews-item-actions';
import getFooterMessage from '../../utils/get-footer-message';
import getActionLabel from '../../utils/get-action-label';
import getActionPopup from '../../utils/get-action-popup';

export function hasAPossibleBulkAction< Item >(
actions: Action< Item >[],
Expand Down Expand Up @@ -157,6 +158,7 @@ function ActionTrigger< Item >( {
icon={ isMobile ? action.icon : undefined }
size="compact"
onClick={ onClick }
aria-haspopup={ getActionPopup( action ) }
isBusy={ isBusy }
>
{ ! isMobile && label }
Expand Down Expand Up @@ -189,6 +191,7 @@ function ActionButton< Item >( {
<Menu.Item
onClick={ onClick }
disabled={ !! action.disabled || isBusy }
aria-haspopup={ getActionPopup( action ) }
>
<Menu.ItemLabel>
{ getActionLabel( action, selectedEligibleItems, 'menu' ) }
Expand Down Expand Up @@ -221,18 +224,20 @@ function renderBulkActionsContent< Item >(
isMobile: boolean,
selectionCheckboxRef?: React.Ref< HTMLSpanElement >
) {
// A text button next to the actions, rather than a close icon at the far
// end, so it can't be read as closing the whole view and stays in sight
// for screen magnifier users.
const clearSelection = selectedItems.length > 0 && (
<Button
className="dataviews-bulk-actions__clear"
icon={ closeSmall }
showTooltip
tooltipPosition="top"
variant="tertiary"
size="compact"
label={ __( 'Cancel' ) }
disabled={ !! actionInProgress }
accessibleWhenDisabled={ false }
onClick={ () => onChangeSelection( EMPTY_ARRAY ) }
/>
>
{ __( 'Clear selection' ) }
</Button>
);
const renderActions = ( isMenuItem = false ) =>
actionsToShow.map( ( action ) => (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@
border-bottom: var(--wpds-border-width-xs) solid var(--wpds-color-stroke-surface-neutral-weak);
}

.dataviews-bulk-actions__clear {
margin-inline-start: auto;
}

.dataviews-bulk-actions__action {
--wp-components-color-accent: var(--wpds-color-foreground-interactive-neutral);
--wp-components-color-accent-darker-20: var(--wpds-color-foreground-interactive-neutral-active);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
import { kebabCase } from '@wordpress/kebab-case';
import type { Action, ActionModal as ActionModalType } from '../../types';
import getActionLabel from '../../utils/get-action-label';
import getActionPopup from '../../utils/get-action-popup';

export interface ActionTriggerProps< Item > {
action: Action< Item >;
Expand Down Expand Up @@ -69,6 +70,7 @@ function ButtonTrigger< Item >( {
size="compact"
variant={ variant }
onClick={ onClick }
aria-haspopup={ getActionPopup( action ) }
>
{ label }
</Button>
Expand All @@ -82,7 +84,11 @@ function MenuItemTrigger< Item >( {
}: ActionTriggerProps< Item > ) {
const label = getActionLabel( action, items, 'menu' );
return (
<Menu.Item disabled={ action.disabled } onClick={ onClick }>
<Menu.Item
disabled={ action.disabled }
onClick={ onClick }
aria-haspopup={ getActionPopup( action ) }
>
<Menu.ItemLabel>{ label }</Menu.ItemLabel>
</Menu.Item>
);
Expand Down
12 changes: 11 additions & 1 deletion packages/dataviews/src/components/dataviews-layout/index.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import type { ComponentType } from 'react';
import { useContext } from '@wordpress/element';
import { Spinner as WCSpinner } from '@wordpress/components';
import { useMergeRefs } from '@wordpress/compose';
import { __ } from '@wordpress/i18n';
import DataViewsContext from '../dataviews-context';
import { VIEW_LAYOUTS } from '../dataviews-layouts';
import { useDelayedLoading } from '../../hooks/use-delayed-loading';
import useFocusFallback from '../../hooks/use-focus-fallback';
import type { ViewBaseProps } from '../../types';

type DataViewsLayoutProps = {
Expand All @@ -20,6 +22,7 @@ export default function DataViewsLayout( { className }: DataViewsLayoutProps ) {
getItemLevel,
hasInitiallyLoaded,
isLoading,
paginationInfo,
view,
onChangeView,
selection,
Expand All @@ -33,6 +36,13 @@ export default function DataViewsLayout( { className }: DataViewsLayoutProps ) {
empty = <p>{ __( 'No results' ) }</p>,
} = useContext( DataViewsContext );

const layoutRef = useMergeRefs( [
containerRef,
useFocusFallback( {
isEmpty: ! isLoading && paginationInfo.totalItems === 0,
isInfiniteScroll: !! view.infiniteScrollEnabled,
} ),
] );
const isDelayedInitialLoading = useDelayedLoading( ! hasInitiallyLoaded, {
delay: 200,
} );
Expand All @@ -59,7 +69,7 @@ export default function DataViewsLayout( { className }: DataViewsLayoutProps ) {
)?.component as ComponentType< ViewBaseProps< any > >;

return (
<div className="dataviews-layout__container" ref={ containerRef }>
<div className="dataviews-layout__container" ref={ layoutRef }>
<ViewComponent
className={ className }
actions={ actions }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,9 @@
// Ensure selection checkbox stays above the preview field.
z-index: 1;
opacity: 0;
// The preview can be any color, including the checkbox's own background
// or border. A ring in the surface color sets it apart from the preview.
box-shadow: 0 0 0 calc(2 * var(--wpds-border-width-xs)) var(--wpds-color-background-surface-neutral-strong);

@media not (prefers-reduced-motion) {
transition: opacity 0.1s linear;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import getDataByGroup from '../utils/get-data-by-group';
import useSelectionProps from '../utils/use-selection-props';
import type { SelectionProps } from '../utils/use-selection-props';
import getActionLabel from '../../../utils/get-action-label';
import getActionPopup from '../../../utils/get-action-popup';

interface ListViewItemProps< Item > {
view: ViewListType;
Expand Down Expand Up @@ -91,6 +92,7 @@ function PrimaryActionGridCell< Item >( {
accessibleWhenDisabled
text={ label }
size="small"
aria-haspopup="dialog"
onClick={ () => setIsModalOpen( true ) }
/>
}
Expand All @@ -113,6 +115,7 @@ function PrimaryActionGridCell< Item >( {
disabled={ !! primaryAction.disabled }
accessibleWhenDisabled
size="small"
aria-haspopup={ getActionPopup( primaryAction ) }
onClick={ () => {
primaryAction.callback( [ item ], { registry } );
} }
Expand Down Expand Up @@ -283,6 +286,15 @@ function ListItem< Item >( {
/>
}
role={ infiniteScrollEnabled ? 'article' : 'row' }
// Otherwise the row is named after all of its content: the title,
// the actions and every field. The fields stay available as the
// description of the item. Without a title, the content is all
// there is to name it by.
aria-labelledby={
renderedTitleField && titleField?.getValue?.( { item } )
? labelId
: undefined
}
className={ clsx( {
'is-selected': isSelected,
'is-hovered': isHovered,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,8 @@
left: var(--wpds-dimension-padding-sm);
// Ensure selection checkbox stays above the preview field.
z-index: 1;
// Set the checkbox apart from previews of any color, as the grid does.
box-shadow: 0 0 0 calc(2 * var(--wpds-border-width-xs)) var(--wpds-color-background-surface-neutral-strong);

@media (hover: none) {
// Show checkboxes on devices that do not support hover.
Expand Down
Loading
Loading