primitives icon indicating copy to clipboard operation
primitives copied to clipboard

Radix Dialog - Events for open and close separately

Open varun-raj opened this issue 3 years ago • 1 comments
trafficstars

Can we have separate events to trigger for onOpen and onClose in a modal?

Currently we've the onOpenChange for radix dialog that triggers whenever the dialog opens or closes. Can we bring a way to have individual events for open and close?

I've a logic for it already, if its required, I can raise a PR

varun-raj avatar Sep 21 '22 11:09 varun-raj

Hi @varun-raj,

What would be the advantage of this? The current API achieves everything without bloating the API surface.

benoitgrelard avatar Sep 21 '22 11:09 benoitgrelard

Closing this issue due to lack of activity, feel free to follow up with more information about the request though.

andy-hook avatar Oct 20 '22 16:10 andy-hook

@andy-hook it seems like the onOpenChange prop is inactive for open event. i am using this version "@radix-ui/react-dialog": "^1.0.2", any thoughts?

TimHuynh0905 avatar May 12 '23 17:05 TimHuynh0905

@TimHuynh0905 what do you mean? Do you have an example sandbox?

benoitgrelard avatar May 16 '23 17:05 benoitgrelard

@benoitgrelard I'm facing the same issue, onOpenChange does not seem to be triggered when open property is switching from false to true.

Here is our usage of the dialog: https://github.com/twentyhq/twenty/blob/b982788100a95a9494e0ec961062e6faa7cf3aa2/front/src/modules/command-menu/components/CommandMenu.tsx#L18

charlesBochet avatar Jul 15 '23 21:07 charlesBochet

@charlesBochet onOpenChange is only triggered when the state is updated internally by Radix

joaom00 avatar Jul 15 '23 23:07 joaom00

mmmh ok, thanks for the answer!

charlesBochet avatar Jul 17 '23 05:07 charlesBochet