Skip to content
This repository was archived by the owner on Sep 30, 2025. It is now read-only.
This repository was archived by the owner on Sep 30, 2025. It is now read-only.

[Modal] Focus isn't trapped in the modal when the primary action is disabled #7728

@acmertz

Description

@acmertz

Issue summary

If a Modal has a primary action with disabled: true, focus isn't trapped in the modal when tabbing over focusable elements.

Expected behavior

Focus wraps around to the first focusable element inside the Modal when tabbing away from the last focusable element.

Actual behavior

User can tab out of the Modal if the primary action is disabled.

https://screenshot.click/polaris-modal-broken-focus-trap.mp4

Steps to reproduce the problem

  1. Create a Modal dialog with a disabled primary action
  2. Open the modal. Focus should automatically move to the first focusable item within the modal.
  3. Start hitting the Tab key on your keyboard. Once the last focusable item before the disabled primary input receives focus, pressing Tab again will move focus outside of the modal to the next focusable item on the rest of the page.

Reduced test case

Edit Polaris Modal disabled primary action focus trap

Specifications

  • Are you using the React components? (Y/N): Y
  • Polaris version number: v10.10.1
  • Browser: Chrome v107
  • Device: MacBook Pro
  • Operating System: macOS Ventura 13.0

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions