Skip to content

Shift-Tab in modal causes background to scroll #41958

@pdeffendol

Description

@pdeffendol

Prerequisites

Describe the issue

When creating and opening a modal via JavaScript, I am experiencing an oddity with keyboard navigation:

  1. Open the modal (in my case it includes a close button in the heading)
  2. Observe that using Tab to navigate places focus on the close button
  3. Use Shift-Tab to navigate backwards. The focus visibly stays on the close button as it's the first and only focusable element inside the modal, but the underlying page scrolls down to the bottom (probably because that's where the modal lies in the overall DOM)

Expected behavior:

  • Using Shift-Tab does not cause body scrolling

Based on investigation it appears that focus temporarily moves to something in the main page before the focus trap resets it to the modal's close button. Will post more detail here if I find it.

Reduced test cases

See issue description

What operating system(s) are you seeing the problem on?

Windows

What browser(s) are you seeing the problem on?

Microsoft Edge, Chrome

What version of Bootstrap are you using?

5.3.8

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions