Open lukewarlow opened 6 months ago
This has come up in a few conversations but primarily from a discussion about adding a 'cancel' (nameTBD) action to invokers for dialogs, and also the light dismiss for dialog discussions.
https://github.com/openui/open-ui/discussions/950#discussioncomment-7592744 - @domenic mentions that this is a useful functionality that we should probably expose.
What problem are you trying to solve?
Dialog elements have an internal close watcher which can trigger cancel events to give web developers a chance to prevent the closure. Currently there's no way for developers to get access to this functionality via anything other than the internal close watcher.
Developers will often want to trigger this same behaviour if closed through other mechanisms such as custom light dismiss for dialogs or even cancel buttons themselves.
What solutions exist today?
The developer would have to implement the cancellation logic twice once for the cancel event handler and another time for their custom cancel behaviour.
How would you solve it?
Exposing a new
requestClose()
function on dialogs that that simplified would be firing the cancel event and then firing close event (and associated dialog closing steps) if cancel wasn't prevented.Anything else?