Skip to content

Restore focus to modal triggering element using { preventScroll: true } #35391

@smares

Description

@smares

Prerequisites

Proposal

If I understand correctly, Bootstrap restores the focus to the triggering element when a modal ist closed.

In some cases, closing a modal will scroll the page to the top. The focus management API (https://html.spec.whatwg.org/multipage/interaction.html#focus-management-apis) says that focus can be passed { preventScroll: true } on supported browsers. https://webplatform.news/issues/2019-04-19#preventing-scroll-into-view-when-calling-focus says that this is especially useful "when dynamically restoring focus after the user closes a modal dialog or reopens a tab panel".

Motivation and context

Closing modals should not scroll the page.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions