Skip to content

Conversation

@ross-u
Copy link

@ross-u ross-u commented Jan 29, 2026

Description

Corrects the explanation of how a modal <dialog> is dismissed when the user presses the Esc key. It clarifies the sequence of events, cancel followed by close, if not prevented, and explains that no explicit return value is provided in this case leaving dialog.returnValue as an empty string.

Motivation

I would like to help and contribute to the MDN documentation and thought to give it a shot with this small issue first. 🙂

Additional details

Related issues and pull requests

Fixes #41656

Corrects the explanation of how a modal `<dialog>` is dismissed when the user presses the Esc key.
It clarifies the sequence of events, `cancel` followed by `close`, if not prevented, and explains that no explicit return value is provided in this case leaving `dialog.returnValue` as an empty string.

Fixes mdn#41656
@ross-u ross-u requested a review from a team as a code owner January 29, 2026 20:34
@ross-u ross-u requested review from chrisdavidmills and removed request for a team January 29, 2026 20:34
@github-actions github-actions bot added Content:HTML Hypertext Markup Language docs size/xs [PR only] 0-5 LoC changed labels Jan 29, 2026
@github-actions
Copy link
Contributor

Preview URLs (1 page)

Copy link
Contributor

@chrisdavidmills chrisdavidmills left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @ross-u, and thank you for your work in fixing this issue.

I've provided a suggestion to tighten up the text a bit, however, I think there is a bigger concern here — the behavior works as described, but only in Chrome.

If you try it in Firefox and Safari, the returnValue is set to an empty string when you press Esc, only if you haven't already selected a value from the dialog dropdown or pressed the dialog "Cancel" button. If you've done one of those two things, then on subsequent presses of the "Show the dialog" button, when you press the Esc key, the returnValue remains set to the previously selected dialog value.

I don't know if this is old behavior, and Chrome's behavior has been updated to spec behavior, or something else. But it is worth investigating this and thinking about how to communicate it in the doc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Content:HTML Hypertext Markup Language docs size/xs [PR only] 0-5 LoC changed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Dialog closure via Escape key now triggers close event

2 participants