Skip to content

Commit

Permalink
[a11y] Fix: Media button on the page view grid does not have an acces…
Browse files Browse the repository at this point in the history
…sible name.
  • Loading branch information
jorgefilipecosta committed Dec 6, 2024
1 parent 2331573 commit f5b2ddd
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions packages/dataviews/src/dataviews-layouts/grid/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
FlexItem,
} from '@wordpress/components';
import { __ } from '@wordpress/i18n';
import { useInstanceId } from '@wordpress/compose';

/**
* Internal dependencies
Expand Down Expand Up @@ -66,6 +67,7 @@ function GridItem< Item >( {
const { showTitle = true, showMedia = true, showDescription = true } = view;
const hasBulkAction = useHasAPossibleBulkAction( actions, item );
const id = getItemId( item );
const instanceId = useInstanceId( GridItem );
const isSelected = selection.includes( id );
const renderedMediaField = mediaField?.render ? (
<mediaField.render item={ item } />
Expand Down Expand Up @@ -112,7 +114,12 @@ function GridItem< Item >( {
} }
>
{ showMedia && renderedMediaField && (
<div { ...clickableMediaItemProps }>{ renderedMediaField }</div>
<div
{ ...clickableMediaItemProps }
aria-labelledby={ `dataviews-view-grid__title-field-${ instanceId }` }
>
{ renderedMediaField }
</div>
) }
{ showMedia && renderedMediaField && (
<DataViewsSelectionCheckbox
Expand All @@ -128,7 +135,10 @@ function GridItem< Item >( {
justify="space-between"
className="dataviews-view-grid__title-actions"
>
<div { ...clickablePrimaryItemProps }>
<div
{ ...clickablePrimaryItemProps }
id={ `dataviews-view-grid__title-field-${ instanceId }` }
>
{ renderedTitleField }
</div>
<ItemActions item={ item } actions={ actions } isCompact />
Expand Down

0 comments on commit f5b2ddd

Please sign in to comment.