-
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
Support for options in .focus() #83
Comments
Drilling a new prop thought all components would be not super easy, however - do we need a new prop?
Any other ideas in mind? |
That's true, it could work with the one prop. Another option to be even more future proof (which is what I was trying to do with another prop) could be:
Essentially, What do you think? |
I like it! That's the real future proof solution! |
Great, I'll draft a PR then. 👍 |
@theKashey here's the PR: #84 |
Not yet released |
|
🙏 awesome |
There seem to be focus-options-polyfill for edge/safari |
still jumping to the top on chrome when used with |
Hey @theKashey, I am looking at adding support for focus options when calling
.focus()
inreturnFocus
.See here: https://github.com/theKashey/react-focus-lock/blob/master/src/Lock.js#L60
The reason for that is that currently when the focus gets returned, if the page has been scrolled down and the element supposed to receive the focus back is not in view anymore, the browser will scroll to reveal that element being focused.
I understand that setting the returning the focus is absolutely important for accessibility and I wouldn't change that. However, it can be a bit disorientating for users to be scrolled to a difference place for what seems to be no apparent reason (to them).
Most latest browsers actually support an option to disable that behaviour if needed.
See the
preventScroll
option (false
by default) on mdn.Here's the current support for it.
I think support is not too much of an issue as this can be seen as an enhancement anyway.
I actually need this feature as part of
react-focus-on
but I know the code for thereturnFocus
handler actually lives inreact-focus-lock
.Would you be willing to add a new prop
returnFocusOptions
to support that optional behaviour?If so, I can draft you a PR today.
Let me know!
✌️
The text was updated successfully, but these errors were encountered: