Skip to content

Add requestClose() function to HTMLDialogElement #10164

@lukewarlow

Description

@lukewarlow

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?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions