-
Notifications
You must be signed in to change notification settings - Fork 22.7k
Technical review: Document <dialog> closeby attribute #39082
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
base: main
Are you sure you want to change the base?
Technical review: Document <dialog> closeby attribute #39082
Conversation
Preview URLs
Flaws (19)URL:
URL:
URL:
(comment last updated: 2025-04-15 09:38:05) |
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.
LGTM! Thanks for documenting this.
|
||
- `none` | ||
|
||
- : No user actions can be used to close the `<dialog>` element, only developer-specified mechanisms such as a JavaScript-powered "Close" {{htmlelement("button")}} or a {{htmlelement("form")}} submission. |
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.
It might be helpful to add a few more bits here. Something like "e.g. <button onclick="dialog.close()">
". As I read this sentence, it sounded like there was some magic declarative way to make a button close the dialog.
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.
This is a good point. We don't tend to use HTML handler attributes on MDN, but I've solved the problem differently:
No user actions can be used to close the
<dialog>
element, only developer-specified mechanisms such as a close {{htmlelement("button")}} (for example with aclick
handler that invokes {{domxref("HTMLDialogElement.close()")}}) or a {{htmlelement("form")}} submission.
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've made this change on the HTML ref page too.
|
||
- `any` | ||
|
||
- : The `<dialog>` element can be closed via relevant platform-specific close requests, or by pressing outside the `<dialog>`. This is equivalent to the ["light dismiss" behavior of "auto" state popovers](/en-US/docs/Web/API/Popover_API/Using#auto_state_and_light_dismiss). |
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.
The word "pressing" is weird. Perhaps "clicking or tapping"?
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.
OK, point taken. I try not to just write "click" in these situations to be mindful of mobile users, but it does sound a bit weird in this context. Updated to "clicking or tapping" throughout.
|
||
## Examples | ||
|
||
```js |
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.
Would an HTML example be good to include, perhaps first? <dialog closedby=any>
?
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.
Good idea. I've done so, and added some more explanation.
|
||
- `none` | ||
|
||
- : No user actions can be used to close the `<dialog>` element, only developer-specified mechanisms such as a JavaScript-powered "Close" {{htmlelement("button")}} or a {{htmlelement("form")}} submission. |
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.
Same comments as above here and below.
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.
All done.
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.
Let me know if you think this PR needs anything else.
Description
Chrome 134 supports the
closedby
attribute of the<dialog>
element: see https://chromestatus.com/feature/5097714453577728.This PR documents the new attribute, plus the equivalent DOM property.
Motivation
Additional details
Related issues and pull requests