-
Notifications
You must be signed in to change notification settings - Fork 67
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
No easy way to control collapsible programmatically #431
Comments
Cycling isOpen to false then true didn't work - presumably I would have needed to give react a cycle of its event loop to handle the switch. Instead, what worked was keeping track of internal collapsible state by listening to onToggle, and updating the input isOpen prop to match. Then, when I wanted to set to Something simpler might be nicer? Though maybe you can't get too simple. If you add a method to do it, a consumer would need to grab a reference to the collapsible. But that might be less effort than keeping their own state and adding event handlers. |
You're spot on with this. Many Paragon components keep an internal state for things like "isOpen" and try to merge it with props. Generally we shouldn't do this. Though, in the case of a Collapsible I think it makes sense to have it be able handle it's own open/closed state. It sounds like we can improve the implementation. If a prop is passed in that should always overrule any internal state. I'll take a look. |
Fixed by #504 |
Looks like it does listen to changes in the prop
isOpen
. But if I'm sitting here and want to ensure the collapsible is open, the only sure fire way to do that is to cycle theisOpen
prop first tofalse
and then totrue
.The text was updated successfully, but these errors were encountered: