-
-
Notifications
You must be signed in to change notification settings - Fork 78.8k
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
Prevent Scrolling back when focus on close #38079
base: main
Are you sure you want to change the base?
Conversation
I am not sure how can we test this, but seems a fair choice |
Thank you @GeoSot for your comment and for your review. I did not create an automated test for this (should I?) But I manually tried it, and it gave exactly the expected behavior, even when I only used the keyboard to navigate. |
as said before, I'd make this an option/parameter that an author can explicitly opt into for their off-canvas, not the default behaviour |
As much as I agree, The only alternative I can think of, is to check a global option. like @ChellyAhmed if we proceed on this, a valid test could be to check that the doc scroll is not changed after closing the offcanvas |
any movement on this? |
Description
This Pull Request is a suggestion to prevent scrolling back to the trigger element on closing off-canvas, all while keeping the behavior of focusing the element unchanged for accessibility. This modification is simply done by adding the
preventScroll: true
object to thethis.focus()
method.Motivation & Context
This PR comes as a better solution for the issue: #38070 . Another PR #38076 is suggested but it solves the issue by completely disabling the focus of the trigger element when the user scrolls. Yet, it is important to focus the trigger element for accessibility.
Type of changes
Checklist
npm run lint
)Live previews
I created a codepen link to preview the changes:
https://codepen.io/ChellyAhmed/pen/VwGLdbR
Related issues
Closes #38070