Skip to content

Unable to cycle focus using tab/shift+tab inside of AnchoredOverlay #1858

@marywhite

Description

@marywhite

Describe the bug
When an AnchoredOverlay allows for keyboard navigation using FocusKeys.Tab, focus will remain trapped on the last focusable element when navigating through the overlay using Tab.

This comment in primer/behavior indicates that the focus trap should be responsible for wrapping focus with Tab (rather than specifying focusOutBehavior: 'wrap')

Because the focus trap rewrites the tabindex=-1 on focusable elements, the focus zone is not able to identify the first focusable element inside of the container when it comes time to wrap.

The below example is a bit contrived, but it seems like the focus zone and trap behaviors do not play nicely together when Tab is eligible for binding.

To Reproduce
Go to sandbox https://codesandbox.io/s/optimistic-villani-6exe7?file=/src/App.js
Click to open menu
Use tab to navigate through the overlay, observe that focus is trapped in the last button

Expected behavior
If FocusKeys.Tab is provided as a bindKey for focus zone, and a focus zone is present, I would expect focus to cycle when a user navigates using Tab.

Desktop (please complete the following information):

  • OS: iOs
  • Browser chrome, safari, firefox

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions