-
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
Check dialog is modal flag instead of open attribute in 'check popover validity' algorithm #9344
Conversation
24e669f
to
35c8661
Compare
35c8661
to
aaf0fa6
Compare
@josepharhar @mfreed7 One side effect of this PR is that you can now run The alternative fix would be throwing an exception if you're trying to close a Any opinions? |
|
||
<li><p>If <var>subject</var> is in its <code>Document</code>'s <span>top layer</span>, then <span | ||
data-x="list remove">remove</span> it.</p></li> | ||
data-x="dom-dialog-returnValue">returnValue</code> attribute to <var>result</var>.</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.
Nit: no additional indentation warranted here.
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.
data-x="dom-dialog-returnValue">returnValue</code> attribute to <var>result</var>.</p></li> | |
data-x="dom-dialog-returnValue">returnValue</code> attribute to <var>result</var>.</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.
@annevk Fixed!
source
Outdated
<li><p><var>element</var> is a <code>dialog</code> element and has an <code | ||
data-x="attr-details-open">open</code> attribute</p></li> | ||
<li><p><var>element</var> is a <code>dialog</code> element and its <span>is modal</span> flag | ||
is set to true.</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 seems reasonable to me, but why wouldn't we check for either the open
attribute or the is modal flag here?
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.
We discussed this a bit more and it makes sense to me that we just care about the top layer conflicts here and not care about potential semantic mismatches.
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.
Hmm, can you say more? I was leaning toward your original suggestion, check for either open
or modal. It feels weird to "direct upgrade" a non-modal dialog to a popover, but maybe it's not so weird.
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 doesn't violate an invariant we're trying to uphold. It's weird, but not really weirder than any of the other things that's possible and doesn't break anything. Whereas top layer conflicts do break things.
If we wanted to make the open
attribute more meaningful we'd probably have to do things when folks remove it and such, but it seems a bit too late to start with that now.
aaf0fa6
to
1d7a1a1
Compare
I like this approach also. I think generally we should throw for this type of "mixing and matching" where it doesn't seem to make sense. |
FWIW, I think the currently proposed approach is nicer as it doesn't bake more of popover into the |
Thinking more, this is tricky, because if you have the sequence:
It wouldn't be unreasonable for |
I guess I don't have strong opinions, and I think that's because I think we should eventually deprecate non-modal Part 2 is:
I think the answer to part 2 is that |
Hmm, yeah, it does throw in that situation. I guess symmetry with |
Right - I was wondering about |
I think the current PR still makes sense. In addition I would suggest that we remove
from |
What about these questions? #9344 (comment) |
@mfreed7 there's no question there? If you mean what would happen with the last |
Right - that question. Ok, so the proposal is:
I think that also sounds reasonable. There might be weird cases when trying to use CSS transitions during popover show/hide, but if you're mixing/matching So ok by me, I think. |
…r validity' algorithm The following case currently does not fail: ``` dialog.showModal(); dialog.open = false; dialog.showPopover(); ``` even though it is a top layer conflict: 1. `showModal` pushes to the top layer 2. `.open = false` then hides the dialog, while keeping it in top layer 3. `showPopover` pushes to the top layer again The check for the open attribute is supposed to prevent top layer conflicts, since those conflicts can leave the element in a broken state, notably after hiding. For instance, the previous sequence of actions followed by `dialog.hidePopover()` will leave the `is modal` flag despite the dialog being completely removed from the top layer. Also only remove from top layer in `HTMLDialogElement.prototype.close()` when the is modal flag is true to prevent that method from removing popovers from the top layer. For `dialog.close()` to be symmetric & consistent with `dialog.show()`, we also stop throwing when `show()` is called on a dialog in the popover showing state. Fixes whatwg#9335
1d7a1a1
to
b600242
Compare
I updated the PR with @annevk's suggestion applied. |
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.
Do we have tests for this change? If OP could point to them that'd be great.
@annevk The WebKit export for WebKit/WebKit#14454 should take care of it. |
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!
https://bugs.webkit.org/show_bug.cgi?id=257412 Reviewed by Tim Nguyen. Check for modal flag instead of open attribute in checkPopoverValidity check: whatwg/html#9344 * LayoutTests/imported/w3c/web-platform-tests/html/semantics/popovers/popover-top-layer-combinations.html: * Source/WebCore/html/HTMLDialogElement.cpp: (WebCore::HTMLDialogElement::show): (WebCore::HTMLDialogElement::close): * Source/WebCore/html/HTMLElement.cpp: (WebCore::checkPopoverValidity): Canonical link: https://commits.webkit.org/264876@main
Adjust test after issue 9344 is merged: whatwg/html#9344
Adjust test after dialog check changed in 'check popover validity': whatwg/html#9344
…40394) Adjust test after dialog check changed in 'check popover validity': whatwg/html#9344
…a=testonly Automatic update from web-platform-tests Adjust test after dialog check changed in 'check popover validity' (#40394) Adjust test after dialog check changed in 'check popover validity': whatwg/html#9344 -- wpt-commits: 37d0fc507b5bd89960107d13500ea2e167f1d3e8 wpt-pr: 40394
…a=testonly Automatic update from web-platform-tests Adjust test after dialog check changed in 'check popover validity' (#40394) Adjust test after dialog check changed in 'check popover validity': whatwg/html#9344 -- wpt-commits: 37d0fc507b5bd89960107d13500ea2e167f1d3e8 wpt-pr: 40394
…a=testonly Automatic update from web-platform-tests Adjust test after dialog check changed in 'check popover validity' (#40394) Adjust test after dialog check changed in 'check popover validity': whatwg/html#9344 -- wpt-commits: 37d0fc507b5bd89960107d13500ea2e167f1d3e8 wpt-pr: 40394 UltraBlame original commit: 4f4e5646bb7993ea1dbf9008632c73392dec0461
…a=testonly Automatic update from web-platform-tests Adjust test after dialog check changed in 'check popover validity' (#40394) Adjust test after dialog check changed in 'check popover validity': whatwg/html#9344 -- wpt-commits: 37d0fc507b5bd89960107d13500ea2e167f1d3e8 wpt-pr: 40394 UltraBlame original commit: 4f4e5646bb7993ea1dbf9008632c73392dec0461
…a=testonly Automatic update from web-platform-tests Adjust test after dialog check changed in 'check popover validity' (#40394) Adjust test after dialog check changed in 'check popover validity': whatwg/html#9344 -- wpt-commits: 37d0fc507b5bd89960107d13500ea2e167f1d3e8 wpt-pr: 40394 UltraBlame original commit: 4f4e5646bb7993ea1dbf9008632c73392dec0461
https://bugs.webkit.org/show_bug.cgi?id=257412 Reviewed by Tim Nguyen. Check for modal flag instead of open attribute in checkPopoverValidity check: whatwg/html#9344 * LayoutTests/imported/w3c/web-platform-tests/html/semantics/popovers/popover-top-layer-combinations.html: * Source/WebCore/html/HTMLDialogElement.cpp: (WebCore::HTMLDialogElement::show): (WebCore::HTMLDialogElement::close): * Source/WebCore/html/HTMLElement.cpp: (WebCore::checkPopoverValidity): Canonical link: https://commits.webkit.org/264876@main
- Replaces the dialog open attribute check in "check popover validity" with an open attribute + isModal check - Removes the exception in dialog.show() which looks at the popover state - Fixes a bug this uncovered in ScheduleForTopLayerRemoval which allowed on element to be listed in the removals multiple times HTML spec PR: whatwg/html#9344 Fixed: 1449442 Change-Id: I74e6189070a1a416d486cbc607f92f964a106d66 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4616893 Commit-Queue: Joey Arhar <[email protected]> Reviewed-by: Mason Freed <[email protected]> Cr-Commit-Position: refs/heads/main@{#1183314}
The following case currently does not fail:
even though it is a top layer conflict:
showModal
pushes to the top layer.open = false
then hides the dialog, while keeping it in top layershowPopover
pushes to the top layer againThe check for the open attribute is supposed to prevent top layer conflicts, since those conflicts can leave the element in a broken state, notably after hiding. For instance, the previous sequence of actions followed by
dialog.hidePopover()
will leave theis modal
flag despite the dialog being completely removed from the top layer.Also only remove from top layer in
HTMLDialogElement.prototype.close()
when the is modal flag istrue to prevent that method from removing popovers from the top layer.
Fixes #9335
(See WHATWG Working Mode: Changes for more details.)
/interactive-elements.html ( diff )
/popover.html ( diff )