Skip to content

Chrome: Window scrolls when returning focus to an element after modal closes #735

@cameracker

Description

@cameracker

Summary:

In chrome, when the modal closes and focus is restored to an element that is scrolled to a non-default position, the window will scroll. In certain settings, such as an editor component like SlateJS or DraftJS, this jump is disorienting to users.

Steps to reproduce:

  1. Have focus on an element scrolled near the top of a window
  2. Open the dialog
  3. Close the dialog
  4. Observe that window scrolls to focus on the original element

Expected behavior:

When focus is restored to an element, the window does not scroll

Link to example of issue:

Admittedly having some trouble reproducing this in a fiddle or code sandbox. Sorry :(

Additional notes:

Requires one line change at https://github.com/reactjs/react-modal/blob/master/src/helpers/focusManager.js#L42 to pass { preventScroll: true } to focus()

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions