-
Notifications
You must be signed in to change notification settings - Fork 23k
Add close button in htmldialogelement/show/index.md example #42053
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Example was missing cancel button. Added a close button matching the /en-US/docs/Web/API/HTMLDialogElement/close example
|
Preview URLs (comment last updated: 2025-11-25 00:27:57) |
| <!-- Simple pop-up dialog box, containing a form --> | ||
| <dialog id="favDialog"> | ||
| <form method="dialog"> | ||
| <button type="button" id="close" aria-label="close">X</button> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you. Can you change this to be "cancel" and then revert the other changes.
The main reason being that the text before this refers to it as a cancel button, and this is a minimal change to meet the original intent.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done. I explicitly set the button label to "Cancel" rather than "X" to show clearer intent.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was the original intent to have the Cancel button be the reset button?
<button type="reset">Reset</button>There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@leevigraham Thanks! To make this easier to use and test the result, I made this a live example. As part of that I reverted the "X" button and updated the text so that it is clear that "Cancel" and X are the same thing - it just looks better. The extra heading levels are how API examples are supposed to be written according to the current web templates. I also modified the layout a little to kill the arbitrary line breaks.
Was the original intent to have the Cancel button be the reset button?
No, the reset button clears the selection in the dialog. We could talk about this but not sure it is relevant to the specific example. Do you think it would be better to delete that button?
Otherwise I am happy to merge this - just wanted to give you a chance to comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given this was my first PR I didn't want to overstep with the live example…
Now I've seen a live example and reviewed the other Instance Method docs I've found some more inconsistencies:
- https://developer.mozilla.org/en-US/docs/Web/API/HTMLDialogElement/close - Looks good
- https://developer.mozilla.org/en-US/docs/Web/API/HTMLDialogElement/requestClose - Could add notes that the
dialog.requestClosemethod triggers thecancelevent - https://developer.mozilla.org/en-US/docs/Web/API/HTMLDialogElement/show - needs live example (this PR)
- https://developer.mozilla.org/en-US/docs/Web/API/HTMLDialogElement/showModal - Has cancel button… but it's the reset button.
I'm happy to attempt to create a PR that update all the Instance Method docs so the live examples all follow the same layout with javascript implementations reflecting the instance method
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That would be welcome. I'll merge this one though.
Note that you might want to link back to this PR to demonstrate the consistency you are trying to achieve. Reason being that I might not be the reviewer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll give it a shot :)
hamishwillee
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @leevigraham !
|
@hamishwillee I've created a new PR for consolidating the dialog examples if you're interested: #42127 |
Description
Example was missing cancel button. Added a close button matching the /en-US/docs/Web/API/HTMLDialogElement/close example
Motivation
Fixing example.
Additional details
N/A
Related issues and pull requests
N/A