Skip to content

Fix "Handling the return value" example#44627

Open
internet-account2 wants to merge 2 commits into
mdn:mainfrom
internet-account2:patch-4
Open

Fix "Handling the return value" example#44627
internet-account2 wants to merge 2 commits into
mdn:mainfrom
internet-account2:patch-4

Conversation

@internet-account2

Copy link
Copy Markdown
Contributor
  • Code description was inaccurate
  • Falsely stated that "Esc" doesn't trigger close event
  • "Confirm" button having a value that is never used is confusing
  • Code didn't check for the initial "" returnValue, which seems like an oversight to me

Description

Fixes inaccuracies and oversights in the example description and code.
Maybe the code could say <option value>Choose…</option> instead of <option value="">Choose…</option>?
And maybe instead of favDialog.returnValue === "" the truthiness could be checked instead.
But probably fine as it is?

Of course it could also check for (favDialog.returnValue === "default" || favDialog.returnValue === "") instead and leave the <option value="default">Choose…</option> untouched, but in any way it probably should check for the initial "" value in some way IMO.

Motivation

Descriptions that don't match the code are confusing.
Code with additional bits that have no influence on the behavior even though they look like they might is confusing.
Code that doesn't handle edge cases makes it easy to forget that they exist, leading to potential bugs along the road.
Clearing those things up will hopefully be beneficial to the average reader.

Additional details

Related issues and pull requests

- Code description was inaccurate
- Falsely stated that "Esc" doesn't trigger close event
- "Confirm" button having a value that is never used is confusing
- Code didn't check for the initial "" returnValue, which seems like an oversight to me
@internet-account2 internet-account2 requested a review from a team as a code owner July 2, 2026 17:00
@internet-account2 internet-account2 requested review from estelle and removed request for a team July 2, 2026 17:00
@github-actions github-actions Bot added Content:HTML Hypertext Markup Language docs size/s [PR only] 6-50 LoC changed labels Jul 2, 2026
@github-actions

github-actions Bot commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Preview URLs (1 page)

(comment last updated: 2026-07-03 13:49:45)

@internet-account2

Copy link
Copy Markdown
Contributor Author

Oh, maybe it should be mentioned that on pressing Esc a cancel event occurs before the close event? I wasn't aware and just read about that. Maybe that would make the different ways to be able to correctly interpret the returnValue more clear.

should make it clear that it's possible to separately handle the cancel event?
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/s [PR only] 6-50 LoC changed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants