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

Keyboard focus is not managed when dynamic content disappears #15329

Closed
karlgroves opened this issue Apr 30, 2019 · 6 comments
Closed

Keyboard focus is not managed when dynamic content disappears #15329

karlgroves opened this issue Apr 30, 2019 · 6 comments
Labels
[Focus] Accessibility (a11y) Changes that impact accessibility and need corresponding review (e.g. markup changes). [Type] Bug An existing feature does not function as intended

Comments

@karlgroves
Copy link

Keyboard focus is not managed when dynamic content disappears

  • Severity: Medium
  • Affected Populations:
    • Blind
    • Low-Vision
    • Motor Impaired
    • Cognitively Impaired
  • Platform(s):
    • All / Universal
  • Components affected:
    • Publish and Unpublish

Issue description

When the "Calendar Help" link or the "Close" button on its popup is
clicked, the focus is reset to the top of the page, in all tested
browsers except Chrome and chromium.

Keyboard and screen reader users rely on predictable and consistent
focus control to navigate the page. When this is absent, users may find
it much more difficult or even impossible to navigate using the
keyboard.

Issue Code
    <!-- when Calendar help is clicked... -->


    <button type="button" class="components-button components-datetime__date-help-button is-link">Calendar Help</button>





    <!-- ...focus should be brought to the popup -->


    <div class="components-popover__content" tabindex="-1" style="max-height: 187.361px;">


        ...<button type="button" class="...">Close</button>...


    </div>





    <!-- when the Close button is clicked, focus should move to Month control -->


    <div class="components-datetime__time-field components-datetime__time-field-month">


        <select aria-label="Month" class="...">...</select>


    </div>

Remediation Guidance

When the "Calendar Help" link is clicked, focus should move to the
popup which is opened (which has tabindex="-1").

When the "Close" button is clicked, focus should move back to the
Calendar Help's first focusable element (the month control).

Relevant standards

Note: This issue may be a duplicate with other existing accessibility-related bugs in this project. This issue comes from the Gutenberg accessibility audit, performed by Tenon and funded by WP Campus. This issue is GUT-15 in Tenon's report

@gziolo gziolo added the Needs Accessibility Feedback Need input from accessibility label Apr 30, 2019
@melchoyce
Copy link
Contributor

Screenshot from full report:

image

@afercia
Copy link
Contributor

afercia commented May 5, 2019

Was able to reproduce with Firefox on the Calendar UI.

For other modals, a similar issue has been mitigated with the introduction of the onFocusLoss option in #14444.

@afercia afercia added [Type] Bug An existing feature does not function as intended [Focus] Accessibility (a11y) Changes that impact accessibility and need corresponding review (e.g. markup changes). and removed Needs Accessibility Feedback Need input from accessibility labels May 5, 2019
@gziolo gziolo added the [Status] In Progress Tracking issues with work in progress label Aug 8, 2019
@nicolad nicolad removed their assignment Mar 16, 2020
@tellthemachines
Copy link
Contributor

Update: this is now only a problem on IE11; it's fixed on all other browsers.

@afercia
Copy link
Contributor

afercia commented Mar 31, 2020

@tellthemachines I'm afraid you're confusing webkit and firefox proprietary behaviors with actual focus.

Modern browsers try to be "smart" and when a part of the DOM is removed or becomes hidden they try to start the tab order from the nearest focusable element. In Chrome, this is called sequential focus navigation starting point and landed in Chrome 50 on April 2016. Firefox already had a similar feature.

This is something completely different from managing focus though. It's just an attempt to restart the tab order from the nearest place so that after a Tab key press you may have the impression a focus loss didn't happen. Instead, it actually happened. Also, this mechanism is not guaranteed to work well with assistive technologies or when large parts of the DOM get removed/hidden.

In any case, when a part of the DOM that contains the currently focused element is removed or hidden, technically there's a focus loss that needs to be managed programmatically.

@skorasaurus skorasaurus removed the [Status] In Progress Tracking issues with work in progress label Feb 9, 2021
@alexstine
Copy link
Contributor

Is this still an issue? I know it is in some parts of the editor, but I am hopeful those have been split in to different issues by now.

@tellthemachines
Copy link
Contributor

Closing as this was fixed in #41097 when DateTimePicker was refactored to use WP components, which handle focus programatically.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Focus] Accessibility (a11y) Changes that impact accessibility and need corresponding review (e.g. markup changes). [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants