-
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
Fix user-agent style rules for top layer transitions #9387
base: main
Are you sure you want to change the base?
Conversation
With the new css-position spec and overlay CSS property, it is possible for ::backdrop and its corresponding element with the popover attribute to be in the top layer while it is transitioning from showing to hidden. During this time, :popover-open does not apply but the element and ::backdrop are still in the top layer, but we still want our popover-specific user-agent style rules for ::backdrop to apply. This PR accomplishes this by moving the ::backdrop style rule from a stylesheet to a more specific definition. This was implemented in chromium by replacing the :popover-open::backdrop selector with an internal pseudo-selector.
This patch adds a new internal pseudo class which matches popovers while they are still in the top layer after they have been closed in order to also make the corresponding ::backdrop stay in the top layer. This is based on futhark's patch: https://chromium-review.googlesource.com/c/chromium/src/+/4554016 HTML spec PR: whatwg/html#9387 Fixed: 1449145 Change-Id: I8e4831e960c5d18fb077f023c119fd0e678541df
This patch adds a new internal pseudo class which matches popovers while they are still in the top layer after they have been closed in order to also make the corresponding ::backdrop stay in the top layer. This is based on futhark's patch: https://chromium-review.googlesource.com/c/chromium/src/+/4554016 HTML spec PR: whatwg/html#9387 Fixed: 1449145 Change-Id: I8e4831e960c5d18fb077f023c119fd0e678541df
@josepharhar Can you solve the issue by just re-writing the UA styles to be this? /* common to fullscreen, dialog, popover */
::backdrop {
display: block;
position: fixed;
inset: 0;
}
/* fullscreen */
:not(:root):fullscreen::backdrop {
background: black;
}
/* modal dialogs */
dialog:not([popover])::backdrop,
dialog[popover]:modal::backdrop {
background: rgba(0, 0, 0, 0.1);
}
/* popovers that aren't fullscreen or modal dialogs */
[popover]:not(:modal)::backdrop {
pointer-events: none;
} |
I'm defining the modal pseudo class here: #9395 |
I think that works. Curious though, can't the
It can only be |
I mostly wrote it that way in case you want the rule to match during a transition, but yeah |
Quickly looking at the implementation in Chrome, :modal does not match after close() going through the transition. |
would cover this case. |
Oh, clever, that's why you wrote it that way. I think there's still a problem though: what if you have I think you do actually need a pseudo state for "is a popover in the top layer", which is what this PR tries to do. |
Calling |
In any case, I think it would be worth looking into cleaning up the UA styles a bit. |
Nevermind, that test is a work in progress and was not working with the changes for this PR anyways |
This patch adds a new internal pseudo class which matches popovers while they are still in the top layer after they have been closed in order to also make the corresponding ::backdrop stay in the top layer. This is based on futhark's patch: https://chromium-review.googlesource.com/c/chromium/src/+/4554016 HTML spec PR: whatwg/html#9387 Fixed: 1449145 Change-Id: I8e4831e960c5d18fb077f023c119fd0e678541df
I'd be supportive of that also, but it unfortunately doesn't solve the problem. You could do We used to have a "transitioning" state explicitly in the spec, but it was unfortunately removed due to pushback. But what we really have here is a state that represents "transitioning". The UA style rules need to apply during transitions. To do that, without exposing the "transitioning" state to JS, we need an internal pseudo class and the equivalent in spec text (i.e., this PR). |
This patch adds a new internal pseudo class which matches popovers while they are still in the top layer after they have been closed in order to also make the corresponding ::backdrop stay in the top layer. This is based on futhark's patch: https://chromium-review.googlesource.com/c/chromium/src/+/4554016 HTML spec PR: whatwg/html#9387 Fixed: 1449145 Change-Id: I8e4831e960c5d18fb077f023c119fd0e678541df Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4585724 Reviewed-by: Mason Freed <[email protected]> Commit-Queue: Joey Arhar <[email protected]> Cr-Commit-Position: refs/heads/main@{#1158640}
This patch adds a new internal pseudo class which matches popovers while they are still in the top layer after they have been closed in order to also make the corresponding ::backdrop stay in the top layer. This is based on futhark's patch: https://chromium-review.googlesource.com/c/chromium/src/+/4554016 HTML spec PR: whatwg/html#9387 Fixed: 1449145 Change-Id: I8e4831e960c5d18fb077f023c119fd0e678541df Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4585724 Reviewed-by: Mason Freed <[email protected]> Commit-Queue: Joey Arhar <[email protected]> Cr-Commit-Position: refs/heads/main@{#1158640}
This patch adds a new internal pseudo class which matches popovers while they are still in the top layer after they have been closed in order to also make the corresponding ::backdrop stay in the top layer. This is based on futhark's patch: https://chromium-review.googlesource.com/c/chromium/src/+/4554016 HTML spec PR: whatwg/html#9387 Fixed: 1449145 Change-Id: I8e4831e960c5d18fb077f023c119fd0e678541df Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4585724 Reviewed-by: Mason Freed <[email protected]> Commit-Queue: Joey Arhar <[email protected]> Cr-Commit-Position: refs/heads/main@{#1158640}
@mfreed7 @josepharhar Here's another idea, it sounded like the Chromium bug report was about the popover & dialog ::backdrop styles not having the same lifespan wrt transitions. The styles above would make it as short for both dialog & popover ^ If the author wants to preserve the ::backdrop styles during the transition, they can add a transition to the backdrop or unconditionally add the background there. |
This could fix the backdrop, but the user-agent styles for the dialog element itself which keep it in the center of the screen also need to stay applied while animating out, during which time the dialog does not match I suppose that in order to fix this, we could move the positioning related styles from the Edit: Moving the whole thing from dialog:modal to dialog won't work since then it would also match non-modal dialogs |
…animating out, a=testonly Automatic update from web-platform-tests Make ::backdrop stay in top layer while animating out This patch adds a new internal pseudo class which matches popovers while they are still in the top layer after they have been closed in order to also make the corresponding ::backdrop stay in the top layer. This is based on futhark's patch: https://chromium-review.googlesource.com/c/chromium/src/+/4554016 HTML spec PR: whatwg/html#9387 Fixed: 1449145 Change-Id: I8e4831e960c5d18fb077f023c119fd0e678541df Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4585724 Reviewed-by: Mason Freed <[email protected]> Commit-Queue: Joey Arhar <[email protected]> Cr-Commit-Position: refs/heads/main@{#1158640} -- wpt-commits: 83976e7d1f6a7b175947209736bd40e94a7cae77 wpt-pr: 40369
…animating out, a=testonly Automatic update from web-platform-tests Make ::backdrop stay in top layer while animating out This patch adds a new internal pseudo class which matches popovers while they are still in the top layer after they have been closed in order to also make the corresponding ::backdrop stay in the top layer. This is based on futhark's patch: https://chromium-review.googlesource.com/c/chromium/src/+/4554016 HTML spec PR: whatwg/html#9387 Fixed: 1449145 Change-Id: I8e4831e960c5d18fb077f023c119fd0e678541df Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4585724 Reviewed-by: Mason Freed <[email protected]> Commit-Queue: Joey Arhar <[email protected]> Cr-Commit-Position: refs/heads/main@{#1158640} -- wpt-commits: 83976e7d1f6a7b175947209736bd40e94a7cae77 wpt-pr: 40369
I pushed some commits for similar fixes for the dialog element, which I learned about and am fixing here: https://bugs.chromium.org/p/chromium/issues/detail?id=1451910 |
This makes it so that while the dialog element is doing an exit animation, its positioning etc. styles from the user-agent stylesheet still apply so it doesnt jump to a different spot while animating out. The :modal class is removed during this time which is why it was a problem before. We also can't just make all dialog elements always have these styles applied, because then they would also apply to non-modal dialogs. Spec: whatwg/html#9387 Fixed: 1451910 Change-Id: I4d2b240ab17879d6cf08f94f32d7c7577e9f53ea
This makes it so that while the dialog element is doing an exit animation, its positioning etc. styles from the user-agent stylesheet still apply so it doesnt jump to a different spot while animating out. The :modal class is removed during this time which is why it was a problem before. We also can't just make all dialog elements always have these styles applied, because then they would also apply to non-modal dialogs. Spec: whatwg/html#9387 Fixed: 1451910 Change-Id: I4d2b240ab17879d6cf08f94f32d7c7577e9f53ea
This makes it so that while the dialog element is doing an exit animation, its positioning etc. styles from the user-agent stylesheet still apply so it doesnt jump to a different spot while animating out. The :modal class is removed during this time which is why it was a problem before. We also can't just make all dialog elements always have these styles applied, because then they would also apply to non-modal dialogs. Spec: whatwg/html#9387 Fixed: 1451910 Change-Id: I4d2b240ab17879d6cf08f94f32d7c7577e9f53ea
This makes it so that while the dialog element is doing an exit animation, its positioning etc. styles from the user-agent stylesheet still apply so it doesnt jump to a different spot while animating out. The :modal class is removed during this time which is why it was a problem before. We also can't just make all dialog elements always have these styles applied, because then they would also apply to non-modal dialogs. Spec: whatwg/html#9387 Fixed: 1451910 Change-Id: I4d2b240ab17879d6cf08f94f32d7c7577e9f53ea Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4739784 Commit-Queue: Joey Arhar <[email protected]> Reviewed-by: Mason Freed <[email protected]> Cr-Commit-Position: refs/heads/main@{#1179848}
This makes it so that while the dialog element is doing an exit animation, its positioning etc. styles from the user-agent stylesheet still apply so it doesnt jump to a different spot while animating out. The :modal class is removed during this time which is why it was a problem before. We also can't just make all dialog elements always have these styles applied, because then they would also apply to non-modal dialogs. Spec: whatwg/html#9387 Fixed: 1451910 Change-Id: I4d2b240ab17879d6cf08f94f32d7c7577e9f53ea Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4739784 Commit-Queue: Joey Arhar <[email protected]> Reviewed-by: Mason Freed <[email protected]> Cr-Commit-Position: refs/heads/main@{#1179848}
This makes it so that while the dialog element is doing an exit animation, its positioning etc. styles from the user-agent stylesheet still apply so it doesnt jump to a different spot while animating out. The :modal class is removed during this time which is why it was a problem before. We also can't just make all dialog elements always have these styles applied, because then they would also apply to non-modal dialogs. Spec: whatwg/html#9387 Fixed: 1451910 Change-Id: I4d2b240ab17879d6cf08f94f32d7c7577e9f53ea Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4739784 Commit-Queue: Joey Arhar <[email protected]> Reviewed-by: Mason Freed <[email protected]> Cr-Commit-Position: refs/heads/main@{#1179848}
@nt1m What do you think of the current state of this PR? I'd like to get multi-implementer interest |
…e in top layer, a=testonly Automatic update from web-platform-tests Make dialog user-agent styles apply while in top layer This makes it so that while the dialog element is doing an exit animation, its positioning etc. styles from the user-agent stylesheet still apply so it doesnt jump to a different spot while animating out. The :modal class is removed during this time which is why it was a problem before. We also can't just make all dialog elements always have these styles applied, because then they would also apply to non-modal dialogs. Spec: whatwg/html#9387 Fixed: 1451910 Change-Id: I4d2b240ab17879d6cf08f94f32d7c7577e9f53ea Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4739784 Commit-Queue: Joey Arhar <[email protected]> Reviewed-by: Mason Freed <[email protected]> Cr-Commit-Position: refs/heads/main@{#1179848} -- wpt-commits: d315170388cc39a79899491733317a74d02e19f1 wpt-pr: 41330
…e in top layer, a=testonly Automatic update from web-platform-tests Make dialog user-agent styles apply while in top layer This makes it so that while the dialog element is doing an exit animation, its positioning etc. styles from the user-agent stylesheet still apply so it doesnt jump to a different spot while animating out. The :modal class is removed during this time which is why it was a problem before. We also can't just make all dialog elements always have these styles applied, because then they would also apply to non-modal dialogs. Spec: whatwg/html#9387 Fixed: 1451910 Change-Id: I4d2b240ab17879d6cf08f94f32d7c7577e9f53ea Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4739784 Commit-Queue: Joey Arhar <[email protected]> Reviewed-by: Mason Freed <[email protected]> Cr-Commit-Position: refs/heads/main@{#1179848} -- wpt-commits: d315170388cc39a79899491733317a74d02e19f1 wpt-pr: 41330
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.
In addition to @nt1m it would be good to see review from @tabatkins too.
<li><span>'pointer-events'</span> property to 'none !important'</li> | ||
<li><span>'background-color'</span> property to 'transparent'</li> | ||
</ul> | ||
|
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: you are eating a newline here.
Sorry for coming in late, but if the existing pseudoclasses aren't sufficient for UA usage, does that indicate they'll similarly be insufficient for author usage? I'm not sure I see why an author would be okay with their If not, the correct path would be to fix the definitions of the pseudoclasses, to match what they actually need to. |
Yeah, we could make the internal pseudoclass a real pseudoclass for authors too. It just didn't seem like an important use case to provide for authors |
A different way to make that happen is to call out the relevant properties in The main awkwardness with this that authors need to remember what properties are involved--but we could solve that by providing a keyword that functions just like a shorthand, expanding out to the relevant set of properties. For example, something like The author can then easily control these properties together as one unit; or split out individual ones by listing them individually later in the list, just like for regular shorthands (e.g. (We could maybe even go a step further and add a generic keyword that computes to the correct set of properties depending on the element involved.) Note: Another solution would be to invent additive cascade and have the UA default stylesheet include these properties together with a |
I see how are are kind of requiring authors to transition overlay, but I'd rather not add even more stuff for authors to include to make the exit animation reasonable. If we end up deprecating and removing non-modal dialog.show(), then we could make these user-agent styles also apply when the dialog is in any state and then none of this stuff would be needed anymore. I'm not sure if this would also work with popover but it might - I'm going to go test it out. |
I think for web developers it would not be that much more work. Instead of |
This makes it so that while the dialog element is doing an exit animation, its positioning etc. styles from the user-agent stylesheet still apply so it doesnt jump to a different spot while animating out. The :modal class is removed during this time which is why it was a problem before. We also can't just make all dialog elements always have these styles applied, because then they would also apply to non-modal dialogs. Spec: whatwg/html#9387 Fixed: 1451910 Change-Id: I4d2b240ab17879d6cf08f94f32d7c7577e9f53ea Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4739784 Commit-Queue: Joey Arhar <[email protected]> Reviewed-by: Mason Freed <[email protected]> Cr-Commit-Position: refs/heads/main@{#1179848}
What is the current status on this? I haven't read all of the above, but just trying to ask some general questions to get things moving: @josepharhar, do you believe the current PR draft represents the best proposal at this point, in light of the above discussions? If so, @annevk @tabatkins @nt1m what do you think of it? |
Yeah I suppose that we could try making |
I don't have strong opinions, but one thing to note: the "modal" nature of the dialog goes away immediately. The only thing that is preserved during an animation is the top layer status. In that sense, |
How does that allow you to style the transition? I'm not seeing it. I still think we need something akin to what @fantasai wrote above and ideally the CSS WG does a thorough review of it first. |
I created a csswg issue to discuss: w3c/csswg-drafts#9912 |
@josepharhar @mfreed7 I actually wonder if the UA styles could be We could also have an additive CSS solution |
If the author uses |
Yeah hence the suggestion for additive CSS: |
The revert-layer bit would need to be a CSSWG addition |
With the new css-position spec and overlay CSS property, it is possible for popovers, dialogs, and their ::backdrops to be in the top layer while transitioning from showing to hidden. During this time, :popover-open and :modal don't apply, but we still want the user-agent styles to apply as if these elements were still showing in the top layer. This PR accomplishes this by moving these styles from selectors with :modal or :popover-open to a definition which says that the element is in the top layer. This is implemented in chromium with an internal pseudo-selector.
These rules can't be accomplished with existing selectors and pseudo-selectors because there is no way to select an element which is transitioning to closed but is still being rendered in the top layer.
(See WHATWG Working Mode: Changes for more details.)
/infrastructure.html ( diff )
/rendering.html ( diff )