x-focus attribute to work in conjunction with x-show #772
earthboundkid
started this conversation in
4. General
Replies: 2 comments 1 reply
-
It's a very specific implementation that fits your use case but we can't force that behaviour for all user. You can achieve the same result using nextTick and settings the focus either when you toggle the variable or using a watcher |
Beta Was this translation helpful? Give feedback.
0 replies
-
Right. I'm just proposing that this is a common need and would let more people get away with components that are just |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
When making a modal or anything that appears and disappears, a lot of my JS ends up just being bookkeeping around what has focus. How about this for time saver: when x-show is toggled to true, it querySelects for a child with x-focus. If it finds one, the current document.activeElement is put into a stack somewhere and that item is focused. On show==false, it restores the old document.activeElement, if it exists.
What do you think?
Beta Was this translation helpful? Give feedback.
All reactions