onClose
gets called on Dialog even when open
state is changed programmatically
#3488
Labels
onClose
gets called on Dialog even when open
state is changed programmatically
#3488
Current behavior
onClose
event gets triggered wheneveropen
state passed touseDialogStore
is changed programmatically. This makes it impossible to distinguish between user-initiated close events (e.g. hitting Esc key or clicking outside the dialog) and programmatic changes to the dialog state, and, as a result, implement certain patterns, such as displaying a warning on dialog hide.Note that this behaviour is not observed when using
open
prop passed directly to theDialog
component, only when using custom dialog store. Existing example on displaying a warning on dialog hide is written usingopen
prop and thus works.Steps to reproduce the bug
Expected behavior
Dialog should close,
onClose
callback should only be called once.Workaround
There is a number of workarounds, e.g.
setOpen
(which glitches, see Dialog's open state is not fully controllable #3402, and as a result, can only be used when dialog has animation)I have a custom Dialog component built around Ariakit's. This essentially means that I have to have 2 implementations depending on whether I use animations or not.
Possible solutions
No response
The text was updated successfully, but these errors were encountered: