Skip to content
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

Fix/keyboard shortcut modal scrolling #45759

Open
wants to merge 2 commits into
base: trunk
Choose a base branch
from

Conversation

tohmjudson
Copy link

What?

Fixes #41500

Why?

Users are unable to scroll inside the keyboard shortcut modal

How?

Adds a container with tabindex to the modal content to allow focus on content div to allow scrolling.

Testing Instructions

  1. Open keyboard shortcut modal
  2. Press tab to highlight the "Close" Button
  3. Press tab again to focus on the shortcut container
  4. Use down and up arrow keys to scroll

Note: This may need an aria-label for the new region. It does not seem to be required to pass or function, but would be helpful to have a non-empty tab stop for screenreader users. I am unsure of how that would work with internationalization so I have not added it yet. This would be inserted at line 204 in packages/components/src/modal/index.tsx

References

https://www.tpgi.com/short-note-on-improving-usability-of-scrollable-regions/
https://dequeuniversity.com/rules/axe/3.5/scrollable-region-focusable
https://accessibilityinsights.io/info-examples/web/scrollable-region-focusable/

Tested:
Safari: Version 16.0 (17614.1.25.9.10, 17614)
Firefox: Version 106.0.5
Chrome: Version 107.0.5304.110

@codesandbox
Copy link

codesandbox bot commented Nov 14, 2022

CodeSandbox logoCodeSandbox logo  Open in CodeSandbox Web Editor | VS Code | VS Code Insiders

@github-actions github-actions bot added the First-time Contributor Pull request opened by a first-time contributor to Gutenberg repository label Nov 14, 2022
@github-actions
Copy link

👋 Thanks for your first Pull Request and for helping build the future of Gutenberg and WordPress, @tohmjudson! In case you missed it, we'd love to have you join us in our Slack community, where we hold regularly weekly meetings open to anyone to coordinate with each other.

If you want to learn more about WordPress development in general, check out the Core Handbook full of helpful information.

@skorasaurus skorasaurus added [Focus] Accessibility (a11y) Changes that impact accessibility and need corresponding review (e.g. markup changes). [a11y] Keyboard & Focus labels Nov 14, 2022
@alexstine alexstine self-requested a review November 14, 2022 23:02
@alexstine
Copy link
Contributor

@tohmjudson Thanks for the PR! Could you please resolve the conflicts?

Thanks.

@tohmjudson tohmjudson force-pushed the fix/keyboard-shortcut-modal-scrolling branch from 9b0c4c5 to fdbdae5 Compare November 15, 2022 19:09
Copy link
Contributor

@alexstine alexstine left a comment

Choose a reason for hiding this comment

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

@tohmjudson Some further thoughts. Please note, this is a fairly difficult issue to solve considering the accessibility issues involved. If you can't solve the A11Y part of this, I can try to help.

@@ -198,7 +198,13 @@ function UnforwardedModal(
) }
</div>
) }
{ children }
<div
Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm, let's not modify the Modal component. The problem only exists in the keyboard shortcuts modal, these changes are not needed globally, right?

<div
className="components-modal__container"
tabIndex={ 0 }
role="region"
Copy link
Contributor

Choose a reason for hiding this comment

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

This region is not going to work here I do not think.

https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles/dialog_role

Does not look like this would really be a valid approach. I wonder what would happen without the role here? Might be worth a try. If we introduce this ARIA here, we'll have to introduce it elsewhere. E.g. Using role="banner", role="main", role="contentinfo". Having one region like this in my opinion would be too confusing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
First-time Contributor Pull request opened by a first-time contributor to Gutenberg repository [Focus] Accessibility (a11y) Changes that impact accessibility and need corresponding review (e.g. markup changes).
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Can not scroll keyboard shorcut window with cursor
4 participants