@alpinejs/focus Configurable displayCheck setting
#4390
Replies: 3 comments 1 reply
-
|
@joshuapease Have you found a solution? |
Beta Was this translation helpful? Give feedback.
-
|
bump. this should be fixed as it makes searchable boxes a nightmare |
Beta Was this translation helpful? Give feedback.
-
|
Hey everyone! Been busy with client projects, but had a bit of free time to dig back in to this. I've been experimenting with two ways of customizing displayCheck. I have some Draft PRs with code, but would love to discuss this with the Alpine JS maintainers before actually opening PRs in this repo (there might be better ways of doing this). Option 1 - Make the focus plugin a factory function. This allows us to pass a config object to the plugin. I tried to write this in a way that also maintains backwards compatibility. Option 2 - Takes inspiration from Chaining Usage: $focus.displayCheck('full') is chained with your function calls. // Examples
this.$focus.displayCheck('full').next()
this.$focus.displayCheck('full').previous()Would love to hear from the maintainers of Alpine if this is a customization we could add to the focus plugin. It unlocks a lot of possibilities, especially when dealing with hidden nav, dropdowns, accordions groups, etc. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I've run into some issues building a disclosure navigation and using the focus plugin.
Child menu items are hidden using
x-show(making themdisplay: none).When I use
@keydown.down="$focus.wrap().next()"and@keydown.up="$focus.wrap().previous()"focus halts when the next focusable element is hidden.My best guess is that tabbable is finding the hidden element, but is unable to focus on it since it's hidden.
If I manually modify the plugin to use
displayCheck: 'full'I get the behavior I'd expect.Here's the spot I would modify.
alpine/packages/focus/src/index.js
Lines 36 to 40 in ab743bc
It seems like other folks have encountered this too:
Beta Was this translation helpful? Give feedback.
All reactions