Skip to content

feat: Mark content outside of popovers inert #145

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
May 30, 2025

Conversation

dcalhoun
Copy link
Member

@dcalhoun dcalhoun commented May 30, 2025

What?

Mark content outside of the block inserter and block inspector inert.

Why?

Close #86. Close CMM-192. Without this, screen readers unexpectedly navigate content that is visually
hidden by the modal popovers.

How?

For the block inserter and block inspector:

  • Enable modal ARIA attribute.
  • Apply the dialog role.
  • Mark content outside of the popover as inert.
  • Enable closing via VoiceOver's two-finger scrub.

Testing Instructions

Tip

Test using the WP-iOS prototype build.

1: Content outside of popover is inert 1

  1. Enable VoiceOver.
  2. Open the block inserter.
  3. Activate the Media tab.
  4. Swipe up with two fingers.
  5. Verify the screen reader does not announce HTML content behind the
    dialog—e.g., block canvas content.

2: Dismiss dialogs with iOS' two-finger scrub

  1. Enable VoiceOver.
  2. Open the block inserter.
  3. Perform a two-finger scrub.
  4. Verify the dialog is dismissed.

Accessibility Testing Instructions

Listed in testing instructions.

Screenshots or screencast

N/A, no visual changes.

Footnotes

  1. This also applies to Android TalkBack, but testing Android with these steps is not possible due to an existing bug: https://github.com/WordPress/gutenberg/issues/70277.

dcalhoun added 3 commits May 30, 2025 11:14
Improve accessibility by hiding content outside of the modals from
screen readers.
Opening a nested settings--e.g., Text color--presents a popover and
moves focus to the new popover. In that case, we do not want to dismiss
the block inspector housing the button that opened the popover.
Buttons rendered within popovers reside in the root body element, thus
we need to hoist this global style override higher.
@dcalhoun dcalhoun added the [Type] Enhancement A suggestion for improvement. label May 30, 2025
'is-quick': isQuick
}),
popoverProps: {
+ ...this.props.popoverProps,
Copy link
Member Author

Choose a reason for hiding this comment

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

Patch to allow improving screen reader accessibility through marking the block inserter as a dialog.

Comment on lines +14 to +17
<div
id="popover-fallback-container"
class="components-popover__fallback-container"
></div>
Copy link
Member Author

Choose a reason for hiding this comment

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

Manually place a "fallback" popover element in the root so that we may query it via its id attribute.

Comment on lines +26 to +28
.components-button {
font-size: $baseline-interactive-font-size;
}
Copy link
Member Author

Choose a reason for hiding this comment

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

Hoist these existing styles to ensure they are applied to buttons within popovers that now render in the root body element.

Comment on lines +53 to +54
useModalize( isInserterOpened );
useModalize( isBlockInspectorShown );
Copy link
Member Author

Choose a reason for hiding this comment

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

Mark content outside of the block inserter and block inspector as inert, so that screen readers cannot read the content aloud when visually obscured by a modal.

dcalhoun added 2 commits May 30, 2025 13:33
Allow setting popover props for the `Inserter` component, so we can
improve the mobile screen reader experience by marking it as a modal
dialog.
@dcalhoun dcalhoun marked this pull request as ready for review May 30, 2025 17:58
@dcalhoun dcalhoun requested a review from nbradbury May 30, 2025 17:58
@nbradbury nbradbury self-assigned this May 30, 2025
Copy link
Contributor

@nbradbury nbradbury left a comment

Choose a reason for hiding this comment

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

Tested and it works as described :shipit:

@dcalhoun dcalhoun merged commit f26928a into trunk May 30, 2025
11 checks passed
@dcalhoun dcalhoun deleted the feat/improve-pop-over-a11y-2 branch May 30, 2025 20:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Type] Enhancement A suggestion for improvement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Improve dialog and pop-over accessibility
2 participants