Is there a way to execute onOpenChange on modals without making it a controlled component?
              
              #9035
            
            Replies: 2 comments
-
| DialogTrigger should be taking over and controlling the state, so you should move the onOpenChange up to there. https://react-spectrum.adobe.com/react-aria/Dialog.html#dialogtrigger | 
Beta Was this translation helpful? Give feedback.
-
| @snowystinger Hey, thanks for the response! Yeah, if I add the  I feel like it would be better if you add this in the docs, inisde the props tables for both DialogTrigger and Modal components. I didn't see any console message most probably because I am still on version  Thanks again! | 
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Initially, I thought the
onOpenChangeon modal overlay's get called when the overlay opens/closes. But looks like that only gets called if I make it a controlled component and pass in theisOpenstate.For example, this will not work.
In order for
onOpenChangeto execute I need to pass theisOpenstate myself and the code will look like below.I want to know if there is a way I can execute some code when the overlay opens/closes without making the component a controlled component?
I want to reset some form fields when the dialog closes and I was hoping to execute
form.reset(defaultValues)withonOpenChange().Beta Was this translation helpful? Give feedback.
All reactions