From 16c8ed1f9d22fc9d9d6b62b6a3444171fd4fdde9 Mon Sep 17 00:00:00 2001 From: internet-account2 <190649829+internet-account2@users.noreply.github.com> Date: Thu, 2 Jul 2026 18:43:53 +0200 Subject: [PATCH 1/2] Fix "Handling the return value" example - 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 --- .../web/html/reference/elements/dialog/index.md | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/files/en-us/web/html/reference/elements/dialog/index.md b/files/en-us/web/html/reference/elements/dialog/index.md index 7f5af8bbb7f82e9..6c78e3fb3067347 100644 --- a/files/en-us/web/html/reference/elements/dialog/index.md +++ b/files/en-us/web/html/reference/elements/dialog/index.md @@ -273,9 +273,9 @@ When the modal dialog is displayed, it appears above any other dialogs that migh This example demonstrates the [`returnValue`](/en-US/docs/Web/API/HTMLDialogElement/returnValue) of the `` element and how to close a modal dialog by using a form. By default, the `returnValue` is the empty string or the value of the button that submits the form within the `` element, if there is one. -This example opens a modal dialog when the "Show the dialog" button is activated. The dialog contains a form with a {{HTMLElement("select")}} and two {{HTMLElement("button")}} elements, which default to `type="submit"`. An event listener updates the value of the "Confirm" button when the select option changes. If the "Confirm" button is activated to close the dialog, the current value of the button is the return value. If the dialog is closed by pressing the "Cancel" button, the `returnValue` is `cancel`. +This example opens a modal dialog when the "Show the dialog" button is activated. The dialog contains a form with a {{HTMLElement("select")}} and two {{HTMLElement("button")}} elements, which default to `type="submit"`. If the "Confirm" button is activated to close the dialog, an event listener sets `returnValue` to the current value of the select box instead of the button's value. If the dialog is closed by pressing the "Cancel" button, the `returnValue` is `cancel`. -When the dialog is closed, the return value is displayed under the "Show the dialog" button. If the dialog is closed by pressing the Esc key, the `returnValue` is not updated, and the `close` event doesn't occur, so the text in the {{HTMLElement("output")}} is not updated. +When the dialog is closed, the return value is displayed under the "Show the dialog" button. If the dialog is closed by pressing the Esc key, the `returnValue` is not updated, but the `close` event still occurs, so the text in the {{HTMLElement("output")}} is "updated" with the (unchanged) `returnValue`. #### HTML @@ -287,7 +287,7 @@ When the dialog is closed, the return value is displayed under the "Show the dia