Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automatic Scroll to First Element in Modal with ScrollView on Safari #2544

Open
1 task done
kidroca opened this issue Jun 23, 2023 · 2 comments
Open
1 task done

Automatic Scroll to First Element in Modal with ScrollView on Safari #2544

kidroca opened this issue Jun 23, 2023 · 2 comments
Labels

Comments

@kidroca
Copy link

kidroca commented Jun 23, 2023

Is there an existing issue for this?

  • I have searched the existing issues

Describe the issue

When opening a Modal that includes a ScrollView or a VirtualList spanning multiple pages, the ScrollView automatically scrolls to the first element. This issue arises from the modal focus trap logic, even when the initialScrollIndex is set to a value other than the index of the first element.

To illustrate this issue, please refer to the steps and accompanying video below:

  1. The intended page is initially displayed.
  2. The modal's focus trap initialization logic triggers focus on the first element inside the ScrollView.
  3. The focused element automatically scrolls itself into view.
Screen.Recording.2023-06-23.at.14.34.34.mov

This issue does not occur in Chrome. It happens only on Safari and mobile Safari.

Expected behavior

Opening a Modal containing a scroll view should not alter the initial scroll position

Steps to reproduce

Environment:

  • OS: macOS Ventura 13.4
  • Browser: Safari Version 16.5 (18615.2.9.11.4)

Steps to reproduce:

  1. Implement a FlatList inside a Modal.
  2. Ensure the FlatList's content is substantial enough to span across multiple pages.
  3. Set the initialScrollIndex to a value representing an item located in the middle of the list.
  4. Open the Modal.

Expected outcome:

  • The modal displays the item at the index specified by initialScrollIndex.

Actual outcome:

  • The modal automatically scrolls to the first item of the list, disregarding the specified initialScrollIndex.

Test case

https://codesandbox.io/s/upbeat-lalande-pjq75x

Additional comments

The issue does not seem to occur if we use Chrome

@kidroca
Copy link
Author

kidroca commented Jul 31, 2023

Is there any information about updates being made to the Modal Focus Trap logic, or other potential solutions that might resolve the issue in question, such as #2483?

I'm hesitant to begin working on a fix that alters the Modal Focus Trap logic without knowing if changes are already planned or underway.

@MrBlackmax
Copy link

MrBlackmax commented Oct 17, 2024

I have the same issue, are there any updates regarding this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants