Replies: 1 comment
-
This is sorely needed. Related requests: I'm working around this by just having a select/deselect all button completely outside of headless (but still within the same containing element with an ![]() While this library is very well made and clean, unfortunately I'm finding it to have large feature gaps and be only suitable for the most basic of use cases. |
Beta Was this translation helpful? Give feedback.
0 replies
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.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi,
I'd really like to be able to implement a custom ListboxOption which doesn't have the same data binding interaction as default, but does have the same keyboard interaction / accessibility as the default.
My use case is that I have a multiselect Listbox, and I want to have a custom option at the top of my ListboxOptions that toggles select all / deselect all.
I tried two approaches but both have downsides. I'm using headlessui with Vue 3 so will use that in my example but I guess the same applies with React.
First of all, adding a custom non-ListboxOption component at the top of my ListboxOptions:
With this approach, the select all works when clicking the option, but using keyboard navigation sees this option skipped, so it's not feasible from an accessibility standpoint.
Second approach was to try and use the ListboxOption, for better UX
The keyboard navigation works here, however I was unable to suppress the built-in effects on the bound data object. I tried using combinations of
@click.prevent
and@click.stop
modifiers but no luck.e.g. suppose I have the following simple Listbox usage.
In this scenario, clicking my select all button twice produces the following console output:
Ideally there would be an option to suppress the default behaviour of a ListboxOption, so it can have custom functionality, but also work nicely with keyboard navigation and accessibility.
e.g. some prop like
suppress-default-behaviour
Beta Was this translation helpful? Give feedback.
All reactions