Skip to content

Commit

Permalink
Implement accessible version of Navigation overlay preview toggle con…
Browse files Browse the repository at this point in the history
…trol (#53462)

* Implement accessible version of overlay preview

* Remove unused id attribute

* Use better wording

Co-authored-by: Alex Stine <alex.stine@yourtechadvisors.com>

* Fix linting

---------

Co-authored-by: Alex Stine <alex.stine@yourtechadvisors.com>
  • Loading branch information
getdave and alexstine committed Aug 11, 2023
1 parent 98e1373 commit 422d12a
Showing 1 changed file with 19 additions and 7 deletions.
26 changes: 19 additions & 7 deletions packages/block-library/src/navigation/edit/index.js
Expand Up @@ -43,6 +43,7 @@ import {
import { __, sprintf } from '@wordpress/i18n';
import { speak } from '@wordpress/a11y';
import { close, Icon } from '@wordpress/icons';
import { useInstanceId } from '@wordpress/compose';

/**
* Internal dependencies
Expand Down Expand Up @@ -500,6 +501,11 @@ function Navigation( {
isFirstRender.current = false;
}, [ submenuAccessibilityNotice ] );

const overlayMenuPreviewId = useInstanceId(
OverlayMenuPreview,
`overlay-menu-preview`
);

const colorGradientSettings = useMultipleOriginColorsAndGradients();
const stylingInspectorControls = (
<>
Expand All @@ -515,6 +521,9 @@ function Navigation( {
! overlayMenuPreview
);
} }
aria-label={ __( 'Overlay menu controls' ) }
aria-controls={ overlayMenuPreviewId }
aria-expanded={ overlayMenuPreview }
>
{ hasIcon && (
<>
Expand All @@ -529,13 +538,16 @@ function Navigation( {
</>
) }
</Button>
{ overlayMenuPreview && (
<OverlayMenuPreview
setAttributes={ setAttributes }
hasIcon={ hasIcon }
icon={ icon }
/>
) }
<div id={ overlayMenuPreviewId }>
{ overlayMenuPreview && (
<OverlayMenuPreview
setAttributes={ setAttributes }
hasIcon={ hasIcon }
icon={ icon }
hidden={ ! overlayMenuPreview }
/>
) }
</div>
</>
) }
<h3>{ __( 'Overlay Menu' ) }</h3>
Expand Down

1 comment on commit 422d12a

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Flaky tests detected in 422d12a.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/5830482492
📝 Reported issues:

Please sign in to comment.