-
-
Notifications
You must be signed in to change notification settings - Fork 31.7k
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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Modal] Scroll changes when focus from browser URL bar #14895
Comments
@mctep Have you found any implementation that handles this case correctly? I can't so far: |
No. Looks like all projects are affected by the issue. |
Hm... If just |
@theKashey has proposed a simple logic to change the behavior in #15450 (comment). |
@oliviertassinari Do you mean fixed hidden sentinels in the body? I have no resources (and have not found any), it is just an idea. @theKashey proposed the right thing. I think it is the simplest workaround to prevent page from scrolling. At least I do not see the easier solution. |
I was wondering if the page scrolling to the top wasn't a good thing. It's what happens when no modal is open. But, once you close the Modal, the focus goes back to the previously activeElement, the page is gonna scroll a second time. I think that we should avoid it, changing the behavior is probably a good idea. You have suggested the usage of a tab index attribute on the body element. However, it will probably harm the Skip-nav link. I would rather avoid any global side effect like this. |
I meant to add However it was a bad idea because by this way we could not detect focus direction. When we press Shift + Tab from the URL bar we should focus to the last element in the Modal. It is possible only when we have two sentinels in the |
In the other hand detecting the last focusable element in the opened modal is non-trivial task. So case with Shift + Tab could be ignored. So I do not see big difference between |
Expected Behavior 馃
When any modal is open the window scroll position should not never change.
Current Behavior 馃槸
When any modal is open we could change scroll by focus through browser address bar.
Steps to Reproduce 馃暪
Link: https://jp6q69qqkv.codesandbox.io/
Context 馃敠
When we focus to window (through Tab press in address bar) Chrome tries to find the first (or the last if we press Shift+Tab) focusable element on the page and focus it. If this element is not in viewport Chrome scrolls the page to this element.
Example source code: https://codesandbox.io/s/8n9wj3vo60
According to: #13702 (comment)
Your Environment 馃寧
The text was updated successfully, but these errors were encountered: