Skip to content

Commit

Permalink
List View: Change the aria-description attribute to aria-describedby (#…
Browse files Browse the repository at this point in the history
…55264)

* List View: Change the aria-description attribute to aria-describedby

* use a unique id
  • Loading branch information
scruffian authored Oct 12, 2023
1 parent 26dae9e commit 617138a
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions packages/block-editor/src/components/list-view/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ import {
useMergeRefs,
__experimentalUseFixedWindowList as useFixedWindowList,
} from '@wordpress/compose';
import { __experimentalTreeGrid as TreeGrid } from '@wordpress/components';
import {
__experimentalTreeGrid as TreeGrid,
VisuallyHidden,
} from '@wordpress/components';
import { AsyncModeProvider, useSelect } from '@wordpress/data';
import deprecated from '@wordpress/deprecated';
import {
Expand Down Expand Up @@ -257,12 +260,20 @@ function ListViewComponent(
return null;
}

const describedById =
description && `block-editor-list-view-description-${ instanceId }`;

return (
<AsyncModeProvider value={ true }>
<ListViewDropIndicator
listViewRef={ elementRef }
blockDropTarget={ blockDropTarget }
/>
{ description && (
<VisuallyHidden id={ describedById }>
{ description }
</VisuallyHidden>
) }
<TreeGrid
id={ id }
className="block-editor-list-view-tree"
Expand All @@ -272,8 +283,7 @@ function ListViewComponent(
onExpandRow={ expandRow }
onFocusRow={ focusRow }
applicationAriaLabel={ __( 'Block navigation structure' ) }
// eslint-disable-next-line jsx-a11y/aria-props
aria-description={ description }
aria-describedby={ describedById }
>
<ListViewContext.Provider value={ contextValue }>
<ListViewBranch
Expand Down

0 comments on commit 617138a

Please sign in to comment.