-
Notifications
You must be signed in to change notification settings - Fork 67
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
[feature request] preventScroll
Option on Focus Override
#162
Comments
A very sound addition very simple to implement. Thank you for providing a good use case, it's really not the best user experience so easy to improve. |
Hi @theKashey, It would be really helpful if we can fix this. Thank you. PR link- theKashey/focus-lock#29 |
@abhimanyu-singh-uber - thank you for the implementation. I'll handle the rest |
Thank you @theKashey |
Wow I just ran into the exact same problem with the exact same use case. Thanks so much for addressing this! |
feat: support focusOptions, fixes #162
|
@theKashey We would need to merge this PR & release react-focus-lock again for the changes to get in. The react-focus-lock is taking in the previous version of focus-lock. |
Description of Feature
Currently,
react-focus-lock
allows you to pass in focus options (includingpreventScroll: true
) to thereturnFocus
prop (see #84 and theKashey/focus-lock#23). I am looking for a prop to add focus options to the logic that brings focus back to the focus lock when a focus event occurs outside of the focus lock.Use-Case
I am creating a
Popover
component that usesreact-focus-lock
that opens when an anchor/reference button is clicked. When thePopover
is open, the user is able to scroll around the page. If the user scrolls to the point where thePopover
is out of view and then clicks on abutton
outside of thePopover
, some browsers (including Chrome) scroll back to the openPopover
. The reason is that some browsers focus abutton
onmousedown
, which I'm assuming causes the focus lock inside of thePopover
to grab focus again. I would like to disable scrolling when thisPopover
focus event occurs usingpreventScroll: true
.Example
Here is a small example of the scroll behavior: https://codesandbox.io/s/react-focus-lock-prevent-scroll-1hjn3?file=/src/App.js
To reproduce:
mousedown
event.The text was updated successfully, but these errors were encountered: