Mobile version should have focus trap

Created on 25 April 2024, over 1 year ago

When using the mobile version of the navigation, it is possible to tab through the admin navigation, and into the content of the page. This violates WCAG 2.4.7 focus visible, because the content item that has focus will be obscured by the navigation menu.

In Olivero we handle this by watching for tabs and redirecting the focus when necessary. A better newererer way to do this would be able to remove focus from focusable elements using the inert attribute (I've used this on client projects).

Either way would work for core though.

πŸ› Bug report
Status

Active

Version

11.0

Component
NavigationΒ  β†’

Last updated 1 day ago

No maintainer
Created by

πŸ‡ΊπŸ‡ΈUnited States mherchel Gainesville, FL, US

Live updates comments and jobs are added and updated live.
  • Accessibility

    It affects the ability of people with disabilities or special needs (such as blindness or color-blindness) to use Drupal.

Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @mherchel
  • πŸ‡ΊπŸ‡ΈUnited States mherchel Gainesville, FL, US
  • πŸ‡ͺπŸ‡ΈSpain ckrina Barcelona
  • πŸ‡ͺπŸ‡ΈSpain ckrina Barcelona
  • πŸ‡ΊπŸ‡ΈUnited States katannshaw Kansas

    I agree with mherchel β†’ that when a user enters the mobile nav, keyboard focus must be trapped within it until the user:

    * Selects the Close/OK/X button
    * Selects the ESC key
    * Clicks outside of the menu with their mouse

    However I disagree on the WCAG success criteria that this violates. I believe that this violates 2.1.2 No Keyboard Trap (Level A). Under an example in this SC titled "A modal dialog box", it mentions:

    A Web application brings up a dialog box. At the bottom of the dialog are two buttons, Cancel and OK. When the dialog has been opened, focus is trapped within the dialog; tabbing from the last control in the dialog takes focus to the first control in the dialog. The dialog is dismissed by activating the Cancel button or the OK button.

    The WCAG 2.4.7 Focus Visible (Level AA) SC refers to the visible focus indicator for focusable elements.

    I like Mike's idea.

  • Merge request !7946First work at abstracting focus trap. β†’ (Open) created by mherchel
  • Pipeline finished with Failed
    over 1 year ago
    Total: 181s
    #166632
  • Pipeline finished with Success
    over 1 year ago
    Total: 675s
    #166642
  • πŸ‡·πŸ‡ΈSerbia finnsky

    Probably it is possible to merge that core/misc/focus-trap.js logic with existing arrow navigation:

    https://git.drupalcode.org/project/drupal/-/blob/11.x/core/modules/navig...

    Or move it on core level out of module.

  • Status changed to Needs review over 1 year ago
  • πŸ‡ΊπŸ‡ΈUnited States mherchel Gainesville, FL, US

    Or move it on core level out of module.

    Yeah, this is my thought. In the MR above, I abstracted it to be on the core level, and then make use of it in both navigation and olivero (to show that it can be used in multiple places).

  • πŸ‡ΊπŸ‡ΈUnited States mherchel Gainesville, FL, US
  • Pipeline finished with Success
    over 1 year ago
    Total: 573s
    #166739
  • πŸ‡·πŸ‡ΈSerbia finnsky

    imo it should be possible to ignore desktop somehow.

  • Status changed to Needs work over 1 year ago
  • πŸ‡ΊπŸ‡ΈUnited States mherchel Gainesville, FL, US

    imo it should be possible to ignore desktop somehow.

    Yeah, that makes sense. Should be doable!

  • πŸ‡«πŸ‡·France nod_ Lille

    The existing tabbingmanager feature has tests, this one should too

  • πŸ‡ΊπŸ‡ΈUnited States kentr Durango, CO

    I believe this would be SC 2.4.11 Focus Not Obscured (Minimum) (Level AA). It directly addresses user openable, persistent disclosures and uses slide-out navigation as an example.

    When the additional content is opened, it takes focus and the tab ring is constrained to the new content until it is dismissed. This modality is somewhat like a dialog, in that a user cannot navigate beyond the opened content by keyboard without dismissing it first (typically by pressing Esc). However, unlike in a modal dialog, in some implementations a pointer user may be able to interact with content outside the opened section without dismissing it. Since this pattern potentially creates an inequitable experience between keyboard and pointer users, it should be used cautiously. That said, it does prevent the opened content from obscuring the keyboard focus in the main content, and thus should pass this SC. This is described and demonstrated in a short video in the Knowbility article in the reference section, under the section heading Keep keyboard focus in the slide-out navigation until it's closed.

  • πŸ‡¨πŸ‡¦Canada mgifford Ottawa, Ontario

    Tagging

Production build 0.71.5 2024