-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Add dialog light dismiss behavior #10737
base: main
Are you sure you want to change the base?
Conversation
First commit is pulled from whatwg#10157
This is exciting! Unfortunately I am going OOO for a week starting ~now, so won't get a chance to review too soon. Hopefully others will be able to help with some reviews, but I would like to get a chance to carefully review the close watcher integration, etc. before this lands. Would you mind commenting on what approach you took to the mutability of the closedby attribute? We discussed that a bit in #9373, and I think we came up with a tentative proposal, but I'm not sure it was battle-tested. |
Looks like |
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 looks great to me!
That's totally fine - no rush. I did this one in the opposite order that I usually do: spec first, prototype after. So I'm moving on to prototype it now, which might reveal other flaws. But I thought since @lukewarlow had gotten the spec into such decent shape, that I'd clean it up and open the PR in case folks saw other flaws there that I could address in the prototype.
As @keithamus said, I just kept what @lukewarlow did in the original PR, and used a new |
<p class="XXX"><span>Light dismiss open popovers</span> will be called by the <a | ||
href="https://github.com/w3c/pointerevents/pull/460">Pointer Events spec</a> when the user clicks | ||
or touches anywhere on the page.</p> | ||
|
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 should be restored.
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.
You'd prefer it to exist in two places? (I moved it up next to the (one) place where the pointer events spec will call into, at <dfn>run light dismiss activities</dfn>
.)
I can add it here also, just double-checking.
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.
No that works. Thanks!
source
Outdated
<p>The <code data-x="attr-dialog-closedby">closedby</code> attribute's <i data-x="invalid value | ||
default">invalid value default</i> and <i data-x="missing value default">missing value | ||
default</i> are both the <dfn data-x="attr-closedby-auto-state">Auto</dfn> state. The <span | ||
data-x="attr-closedby-auto-state">auto</span> state matches <span | ||
data-x="attr-closedby-closerequest-state">closerequest</span> when the element is modal; | ||
otherwise <span data-x="attr-closedby-none-state">none</span>.</p> |
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.
There's very inconsistent spelling of states here. They should match the capitalization and words of how they are introduced. And should typically be followed by the word state (though that's not linked).
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.
Also, perhaps the statement of fact is better as a note?
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.
There's very inconsistent spelling of states here. They should match the capitalization and words of how they are introduced. And should typically be followed by the word state (though that's not linked).
Yep, I agree. I fixed them all up, I think. Please let me know if you see any others I missed. All are now lowercase.
Also, perhaps the statement of fact is better as a note?
Sorry - can you help me understand this? Which "statement of fact"?
This CL puts the feature flag in place, adds (flag guarded) closedBy and requestClose() methods to <dialog>, connects the pointer events handling to a new dialog light dismiss method, and adds a basic set of tests. None of the actual functionality is here yet, this is just a shell. Subsequent CLs will flesh out the behavior. See spec PR for details: whatwg/html#10737 Here's the chromestatus: https://chromestatus.com/feature/5097714453577728 Bug: 376516550 Change-Id: I3727ca21476a2a3340fd18597970395d64ef7176
This CL puts the feature flag in place, adds (flag guarded) closedBy and requestClose() methods to <dialog>, connects the pointer events handling to a new dialog light dismiss method, and adds a basic set of tests. None of the actual functionality is here yet, this is just a shell. Subsequent CLs will flesh out the behavior. See spec PR for details: whatwg/html#10737 Here's the chromestatus: https://chromestatus.com/feature/5097714453577728 Bug: 376516550 Change-Id: I3727ca21476a2a3340fd18597970395d64ef7176
This CL puts the feature flag in place, adds (flag guarded) closedBy and requestClose() methods to <dialog>, connects the pointer events handling to a new dialog light dismiss method, and adds a basic set of tests. None of the actual functionality is here yet, this is just a shell. Subsequent CLs will flesh out the behavior. See spec PR for details: whatwg/html#10737 Here's the chromestatus: https://chromestatus.com/feature/5097714453577728 Bug: 376516550 Change-Id: I3727ca21476a2a3340fd18597970395d64ef7176 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5985491 Commit-Queue: Mason Freed <masonf@chromium.org> Reviewed-by: David Baron <dbaron@chromium.org> Cr-Commit-Position: refs/heads/main@{#1378633}
This CL puts the feature flag in place, adds (flag guarded) closedBy and requestClose() methods to <dialog>, connects the pointer events handling to a new dialog light dismiss method, and adds a basic set of tests. None of the actual functionality is here yet, this is just a shell. Subsequent CLs will flesh out the behavior. See spec PR for details: whatwg/html#10737 Here's the chromestatus: https://chromestatus.com/feature/5097714453577728 Bug: 376516550 Change-Id: I3727ca21476a2a3340fd18597970395d64ef7176 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5985491 Commit-Queue: Mason Freed <masonf@chromium.org> Reviewed-by: David Baron <dbaron@chromium.org> Cr-Commit-Position: refs/heads/main@{#1378633}
This implements reflection of `closedBy` including the "limited to known values" behavior. See spec PR for details: whatwg/html#10737 Bug: 376516550 Change-Id: Iddefd573fe19fd39f4b3aebe13390235fea969b9
This implements reflection of `closedBy` including the "limited to known values" behavior. See spec PR for details: whatwg/html#10737 Bug: 376516550 Change-Id: Iddefd573fe19fd39f4b3aebe13390235fea969b9
This implements reflection of `closedBy` including the "limited to known values" behavior. See spec PR for details: whatwg/html#10737 Bug: 376516550 Change-Id: Iddefd573fe19fd39f4b3aebe13390235fea969b9 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5988652 Commit-Queue: Mason Freed <masonf@chromium.org> Reviewed-by: David Baron <dbaron@chromium.org> Commit-Queue: David Baron <dbaron@chromium.org> Auto-Submit: Mason Freed <masonf@chromium.org> Cr-Commit-Position: refs/heads/main@{#1379228}
This implements reflection of `closedBy` including the "limited to known values" behavior. See spec PR for details: whatwg/html#10737 Bug: 376516550 Change-Id: Iddefd573fe19fd39f4b3aebe13390235fea969b9 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5988652 Commit-Queue: Mason Freed <masonf@chromium.org> Reviewed-by: David Baron <dbaron@chromium.org> Commit-Queue: David Baron <dbaron@chromium.org> Auto-Submit: Mason Freed <masonf@chromium.org> Cr-Commit-Position: refs/heads/main@{#1379228}
This implements reflection of `closedBy` including the "limited to known values" behavior. See spec PR for details: whatwg/html#10737 Bug: 376516550 Change-Id: Iddefd573fe19fd39f4b3aebe13390235fea969b9 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5988652 Commit-Queue: Mason Freed <masonf@chromium.org> Reviewed-by: David Baron <dbaron@chromium.org> Commit-Queue: David Baron <dbaron@chromium.org> Auto-Submit: Mason Freed <masonf@chromium.org> Cr-Commit-Position: refs/heads/main@{#1379228}
This enables `closedby=none` to *stop* the dialog from closing when the ESC key (or other close signal) is received. See spec PR for details: whatwg/html#10737 Bug: 376516550 Change-Id: I0bf7fc7a50acaffb89e183fe6e19f411de4da576 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5990171 Reviewed-by: David Baron <dbaron@chromium.org> Commit-Queue: Mason Freed <masonf@chromium.org> Cr-Commit-Position: refs/heads/main@{#1379279}
…ht dismiss [1/N], a=testonly Automatic update from web-platform-tests Implement basic structure for dialog light dismiss [1/N] This CL puts the feature flag in place, adds (flag guarded) closedBy and requestClose() methods to <dialog>, connects the pointer events handling to a new dialog light dismiss method, and adds a basic set of tests. None of the actual functionality is here yet, this is just a shell. Subsequent CLs will flesh out the behavior. See spec PR for details: whatwg/html#10737 Here's the chromestatus: https://chromestatus.com/feature/5097714453577728 Bug: 376516550 Change-Id: I3727ca21476a2a3340fd18597970395d64ef7176 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5985491 Commit-Queue: Mason Freed <masonf@chromium.org> Reviewed-by: David Baron <dbaron@chromium.org> Cr-Commit-Position: refs/heads/main@{#1378633} -- wpt-commits: 1d5037cc3ff4524fd5d9f1a461afd20aebbb0839 wpt-pr: 48976
…alog closedBy [2/N], a=testonly Automatic update from web-platform-tests Add attribute reflection behavior for dialog closedBy [2/N] This implements reflection of `closedBy` including the "limited to known values" behavior. See spec PR for details: whatwg/html#10737 Bug: 376516550 Change-Id: Iddefd573fe19fd39f4b3aebe13390235fea969b9 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5988652 Commit-Queue: Mason Freed <masonf@chromium.org> Reviewed-by: David Baron <dbaron@chromium.org> Commit-Queue: David Baron <dbaron@chromium.org> Auto-Submit: Mason Freed <masonf@chromium.org> Cr-Commit-Position: refs/heads/main@{#1379228} -- wpt-commits: 28946b88d5b2e037bb2506ae4984e8725ba5560b wpt-pr: 48989
This implements dialog.requestClose() and adds a test. See spec PR for details: whatwg/html#10737 Bug: 376516550 Change-Id: Iaac3d89c28844d2b54ff5b1a7b68dc356d1fd172
default</i> are both the <dfn data-x="attr-closedby-auto-state">auto</dfn> state. The <span | ||
data-x="attr-closedby-auto-state">auto</span> state matches <span | ||
data-x="attr-closedby-closerequest-state">close request</span> state when the element is modal; | ||
otherwise the <span data-x="attr-closedby-none-state">none</span> state.</p> |
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 statement about the auto state is better done as a note I think. At least presumably the actual requirements that lead to this are elsewhere.
data-x="attr-closedby-any-state">Any</span> or <span | ||
data-x="attr-closedby-closerequest-state">Close Request</span>; otherwise false.</p></li> |
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.
You didn't change the casing consistently it seems. I have to say I actually prefer this casing as it makes it clearer what the states are relative to the values.
return.</p></li> | ||
|
||
<li><p>If <var>oldValue</var> and <var>value</var> are in the same <span | ||
data-x="attr-dialog-closedby">state</span>, then return.</p></li> |
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 reads a little weird. Could you file a follow-up issue to improve this as it's not immediately clear to me what the correct wording would be and it does seem like we want to be able to do this.
<li><p><span>Assert</span>: <var>element</var>'s <span data-x="dialog-close-watcher">close | ||
watcher</span> is not null.</p></li> | ||
|
||
<li><p>If <var>value</var> is in the <span data-x="attr-closedby-any-state">Any</span> state, |
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.
Here I think we can talk about the state of element's closedby attribute, no?
@@ -62046,7 +62167,134 @@ interface <dfn interface>HTMLDialogElement</dfn> : <span>HTMLElement</span> { | |||
</dialog></code></pre> | |||
</div> | |||
|
|||
<h4><dfn>Dialog light dismiss</dfn></h4> | |||
|
|||
<p class="note">"Light dismiss" means that clicking outside of a dialog whose <code |
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.
dialog element* (also needs code)
|
||
<li><p>Let <var>document</var> be <var>target</var>'s <span>node document</span>.</p></li> | ||
|
||
<li><p>If <var>document</var>'s <span>light dismissible dialog list</span> is empty, then |
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.
xref is empty
<li><p>Let <var>dialogs</var> be « ».</p></li> | ||
|
||
<li><p><span data-x="list iterate">For each</span> <code>Element</code> <var>element</var> in | ||
<var>document</var>: if <var>element</var> is a <code data-x="HTMLDialogElement">dialog element</code>, |
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.
Order? I'm also not sure if "element in document" works. "element in document's descendants" maybe?
return <var>currentNode</var>.</p></li> | ||
|
||
<li><p>Set <var>currentNode</var> to <var>currentNode</var>'s parent in the <span>flat | ||
tree</span>.</p></li> |
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.
Should this use the flat tree or the composed tree?
<p class="XXX"><span>Light dismiss open popovers</span> will be called by the <a | ||
href="https://github.com/w3c/pointerevents/pull/460">Pointer Events spec</a> when the user clicks | ||
or touches anywhere on the page.</p> | ||
|
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.
No that works. Thanks!
This implements dialog.requestClose() and adds a test. See spec PR for details: whatwg/html#10737 Bug: 376516550 Change-Id: Iaac3d89c28844d2b54ff5b1a7b68dc356d1fd172
This implements dialog.requestClose() and adds a test. See spec PR for details: whatwg/html#10737 Bug: 376516550 Change-Id: Iaac3d89c28844d2b54ff5b1a7b68dc356d1fd172 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5991017 Commit-Queue: Mason Freed <masonf@chromium.org> Reviewed-by: David Baron <dbaron@chromium.org> Auto-Submit: Mason Freed <masonf@chromium.org> Cr-Commit-Position: refs/heads/main@{#1380450}
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 also just noticed you forgot to update the indexes. There's a checklist at the top of source
for what to change when you add a new attribute.
<th>Brief description | ||
<tbody> | ||
<tr> | ||
<td><dfn attr-value for="dialog/closedby"><code data-x="attr-closedby-any">any</code></dfn> |
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 should be attr-dialog-closedby-
here and elsewhere.
This implements dialog.requestClose() and adds a test. See spec PR for details: whatwg/html#10737 Bug: 376516550 Change-Id: Iaac3d89c28844d2b54ff5b1a7b68dc356d1fd172 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5991017 Commit-Queue: Mason Freed <masonf@chromium.org> Reviewed-by: David Baron <dbaron@chromium.org> Auto-Submit: Mason Freed <masonf@chromium.org> Cr-Commit-Position: refs/heads/main@{#1380450}
This implements dialog.requestClose() and adds a test. See spec PR for details: whatwg/html#10737 Bug: 376516550 Change-Id: Iaac3d89c28844d2b54ff5b1a7b68dc356d1fd172 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5991017 Commit-Queue: Mason Freed <masonf@chromium.org> Reviewed-by: David Baron <dbaron@chromium.org> Auto-Submit: Mason Freed <masonf@chromium.org> Cr-Commit-Position: refs/heads/main@{#1380450}
…ht dismiss [1/N], a=testonly Automatic update from web-platform-tests Implement basic structure for dialog light dismiss [1/N] This CL puts the feature flag in place, adds (flag guarded) closedBy and requestClose() methods to <dialog>, connects the pointer events handling to a new dialog light dismiss method, and adds a basic set of tests. None of the actual functionality is here yet, this is just a shell. Subsequent CLs will flesh out the behavior. See spec PR for details: whatwg/html#10737 Here's the chromestatus: https://chromestatus.com/feature/5097714453577728 Bug: 376516550 Change-Id: I3727ca21476a2a3340fd18597970395d64ef7176 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5985491 Commit-Queue: Mason Freed <masonf@chromium.org> Reviewed-by: David Baron <dbaron@chromium.org> Cr-Commit-Position: refs/heads/main@{#1378633} -- wpt-commits: 1d5037cc3ff4524fd5d9f1a461afd20aebbb0839 wpt-pr: 48976
…alog closedBy [2/N], a=testonly Automatic update from web-platform-tests Add attribute reflection behavior for dialog closedBy [2/N] This implements reflection of `closedBy` including the "limited to known values" behavior. See spec PR for details: whatwg/html#10737 Bug: 376516550 Change-Id: Iddefd573fe19fd39f4b3aebe13390235fea969b9 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5988652 Commit-Queue: Mason Freed <masonf@chromium.org> Reviewed-by: David Baron <dbaron@chromium.org> Commit-Queue: David Baron <dbaron@chromium.org> Auto-Submit: Mason Freed <masonf@chromium.org> Cr-Commit-Position: refs/heads/main@{#1379228} -- wpt-commits: 28946b88d5b2e037bb2506ae4984e8725ba5560b wpt-pr: 48989
…=testonly Automatic update from web-platform-tests Implement dialog.requestClose() [4/N] This implements dialog.requestClose() and adds a test. See spec PR for details: whatwg/html#10737 Bug: 376516550 Change-Id: Iaac3d89c28844d2b54ff5b1a7b68dc356d1fd172 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5991017 Commit-Queue: Mason Freed <masonf@chromium.org> Reviewed-by: David Baron <dbaron@chromium.org> Auto-Submit: Mason Freed <masonf@chromium.org> Cr-Commit-Position: refs/heads/main@{#1380450} -- wpt-commits: 97a34c26ea3a3bfeacc0f40fc733d464c3f4d377 wpt-pr: 49050
…=testonly Automatic update from web-platform-tests Implement dialog.requestClose() [4/N] This implements dialog.requestClose() and adds a test. See spec PR for details: whatwg/html#10737 Bug: 376516550 Change-Id: Iaac3d89c28844d2b54ff5b1a7b68dc356d1fd172 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5991017 Commit-Queue: Mason Freed <masonf@chromium.org> Reviewed-by: David Baron <dbaron@chromium.org> Auto-Submit: Mason Freed <masonf@chromium.org> Cr-Commit-Position: refs/heads/main@{#1380450} -- wpt-commits: 97a34c26ea3a3bfeacc0f40fc733d464c3f4d377 wpt-pr: 49050
This adds a few things:
A
closedby
attribute that can be used to control the light dismiss behavior of dialogs:<dialog closedby=none>
- no user-triggered closing of dialogs at all.<dialog closedby=closerequest>
- user pressing ESC (or other close trigger) closes the dialog<dialog closedby=any>
- user clicking outside the dialog, or pressing ESC, closes the dialog. Akin topopover=auto
behavior.<dialog>
- i.e. noclosedby
attribute - default/old behavior. Behaves likeclosedby=closerequest
.This PR also (per the request) adds a
dialog.requestClose()
which fires thecancel
event, and then (if that isn't cancelled) fires theclose
event and closes the dialog.I also consolidated the "light dismiss" activities into one algorithm, which will need to be called by Add popover light dismiss integration w3c/pointerevents#460 if that ever gets some attention.
Some interesting related links:
<dialog>
#9373 - the WHATWG discussionclosedby
closerequest
Closes #9373
(See WHATWG Working Mode: Changes for more details.)
/index.html ( diff )
/interaction.html ( diff )
/interactive-elements.html ( diff )
/popover.html ( diff )