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

returnToFocus option #11

Closed
benoitgrelard opened this issue Jul 15, 2019 · 3 comments
Closed

returnToFocus option #11

benoitgrelard opened this issue Jul 15, 2019 · 3 comments

Comments

@benoitgrelard
Copy link
Contributor

Hi,

First, thanks for this great library.
I was wondering why returnToFocus was hardcoded as true and not passed as an option to FocusLock like the others. (see https://github.com/theKashey/react-focus-on/blob/master/src/UI.tsx#L37)

The use case I am trying to provide is, by default let your library handle the return focus, but if the user passes a custom ref to focus when the modal gets close, focus on that instead.

The issue is that for this to work, I have to write my ref.focus() in something like setImmediate or requestAnimationFrame to wait for the normal returnToFocus to do its thing first (I'm doing this in onDeactivation callback). Instead I would like to set returnToFocus={false} when a custom ref is passed into my component.

I hope this make sense.
I tested it with react-focus-lock and it worked well by setting returnToFocus={false} and focusing my own thing using onDeactivation callback.

Thanks 🙏

@theKashey
Copy link
Owner

Sounds legit 👍

@theKashey
Copy link
Owner

3.0.4

@benoitgrelard
Copy link
Contributor Author

Wow, thanks for the quick turnaround! 👌

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

No branches or pull requests

2 participants