Skip to content

Dialog closure via Escape key now triggers close event #41656

@alec-mitnik

Description

@alec-mitnik

MDN URL

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/dialog

What specific section or headline is this issue about?

Handling the return value from the dialog

What information was incorrect, unhelpful, or incomplete?

"If the dialog is closed by pressing the Esc key, the returnValue is not updated, and the close event doesn't occur"

What did you expect to see?

If this were true, in the live example that follows, closing the dialog with Escape should not change the Output content. However, at least for Windows on Chrome, the Output is set to "ReturnValue: ." indicating that the close event is getting triggered and the dialog returnValue is getting set to empty string.

I don't know if this might be specific to Chrome or Windows or something. Maybe its behavior is against spec. I certainly think that Escape triggering the close event and setting the returnValue is much preferable to it doing neither, at any rate.

But even if it were somehow due to the spec not being appropriately adhered to, it would still be very important to clarify in this documentation that the statement "If the dialog is closed by pressing the Esc key, the returnValue is not updated, and the close event doesn't occur" does not necessarily hold true, and should not be relied on for production code.

And if it turns out the statement is just entirely outdated or incorrect, then it can simply be removed or appropriately edited.

Do you have any supporting links, references, or citations?

Only my own firsthand observation.

Do you have anything more you want to share?

No response

MDN metadata

Page report details

Metadata

Metadata

Assignees

No one assigned

    Labels

    Content:HTMLHypertext Markup Language docshelp wantedIf you know something about this topic, we would love your help!

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions