Replies: 11 comments 3 replies
-
I had this same issue. I want to open the listbox from another component and I can't figure out how to programmatically change the open state since it's a render prop. Is there any work arounds? I wish it worked like Dialog too. |
Beta Was this translation helpful? Give feedback.
-
currently only the dialog has it: would love for all components to have this same option. |
Beta Was this translation helpful? Give feedback.
-
💯 Wondering why this simple, yet critical feature doesn’t exist for the other components. Was able to create a workaround: <Popover>
<Popover.Button onClick={() => setOpen(prev => !prev)}>
... |
Beta Was this translation helpful? Give feedback.
-
Same need here. Another idea would be to at least expose onOpen, onClose events. |
Beta Was this translation helpful? Give feedback.
-
Same need. |
Beta Was this translation helpful? Give feedback.
-
Same need. I have a sidebar Menu that I'd like to open by default in some cases. I could just force this with the static property, but then closing it becomes awkward. Would be great to be able to just pass in the open state as a prop, or at least hook into change events so that I could keep my other state in sync |
Beta Was this translation helpful? Give feedback.
-
I need this for a ListBox. Having to reimplement all the existing triggers to mutate the open state is a lot of work, and defeats the purpose of using the component. I have some non standard omponents inside the listbox, that need to when clicked be able to close the listbox just like the standard ListBoxOption. |
Beta Was this translation helpful? Give feedback.
-
Has anyone found any workarounds for replicating onOpen/onClose events for components that don't have them exposed (which appears to be most)? |
Beta Was this translation helpful? Give feedback.
-
same issue, but I found a solution for me. I created buttons with position absolute (fake outside). When I click a button above (like close, clear all, apply filter), it will run
|
Beta Was this translation helpful? Give feedback.
-
Following up on this, it would be very helpful to be able to the open/close states from other components while retaining the native UI behaviour. Using an onClick is helpful for tracking when a Listbox has been opened, but you lose the closed state when the Listbox is closed. |
Beta Was this translation helpful? Give feedback.
-
I managed to work around this issue by splitting my Listbox component into two and using a ref to hold the current open state provided by HeadlessUI Listbox render prop. For instance, using HeadlessUI Listbox basic example, first:
Then :
And to use it :
|
Beta Was this translation helpful? Give feedback.
-
Hi. I really like the idea of headless components. But I found it really inconvenient to use in some advanced cases. Especially if I want to open and close something programmatically. That would be really amazing if you provide the component's state as a hook. I really don't like the render prop pattern as it makes the code look ugly.
What if we allow to pass
open
andsetOpen
from the outside? Like you already do in theDialog
component. It would make other components much more flexible.For example, I was trying to implement input suggestions. The suggestions' window should open when user starts typing. Unfortunately I could not make it work using
Listbox
,Popover
orMenu
. Because there is no way to open it programmatically. Please consider exposing the open state somehow.Also it would be great if you export all your internal hooks from the package. They are really useful when you want to build your own interactive component.
Beta Was this translation helpful? Give feedback.
All reactions