-
Notifications
You must be signed in to change notification settings - Fork 62
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
Preserve focus #23
Preserve focus #23
Conversation
@lukemelia I'm +1 on this, what do you think? |
Seems OK to me. Could this behavior be problematic in some circumstances? Do we need an opt out? |
It seems unlikely, but I'm not certain. I initially considered only refocusing if the previously-focused element was part of the wormhole'd content, which is a little more expensive to calculate but feels slightly safer. BUT — I'd consider the current loss of focus to be an undefined/undocumented behavior (if not an outright bug), so perhaps this PR could include some documentation defining the new behavior and leave it at that. Thoughts? |
Let's start with docs on this and we'll see if we get any reports of issues. I'm concerned that people who have events set on focus may be surprised to have them running twice. Then again, to the point of this PR, they may be surprised to have lost focus too. |
We're working around this in our Ember app by storing the focus state and re-focusing manually if the wormhole activates. Would like to see focus preserved :) |
@lukemelia I think the latter is more surprising and this should just be merged. |
I'm sold. Merged. |
Thanks @adamesque! |
Thank you! |
Currently, if you have a component that attempts to shift focus on
didInsertElement
, and you wrap that component in a wormhole, it's possible for focus to be lost because the inner component'sdidInsertElement
fires before ember-wormhole's, and focus is lost when reparenting DOM elements.This PR ensures that the element that has focus prior to
appendToDestination
retains focus once the append operation is complete. Should resolve #22.