Skip to content
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

Add requestClose() function to HTMLDialogElement #10164

Open
lukewarlow opened this issue Feb 26, 2024 · 1 comment
Open

Add requestClose() function to HTMLDialogElement #10164

lukewarlow opened this issue Feb 26, 2024 · 1 comment
Labels
addition/proposal New features or enhancements needs implementer interest Moving the issue forward requires implementers to express interest topic: close watchers topic: dialog The <dialog> element.

Comments

@lukewarlow
Copy link
Member

lukewarlow commented Feb 26, 2024

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?

@lukewarlow lukewarlow added addition/proposal New features or enhancements needs implementer interest Moving the issue forward requires implementers to express interest labels Feb 26, 2024
@lukewarlow
Copy link
Member Author

lukewarlow commented Feb 26, 2024

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.

openui/open-ui#950 (reply in thread) - @domenic mentions that this is a useful functionality that we should probably expose.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
addition/proposal New features or enhancements needs implementer interest Moving the issue forward requires implementers to express interest topic: close watchers topic: dialog The <dialog> element.
Development

No branches or pull requests

2 participants