Repository navigation
Description
TL;DR: This is a follow-on from #6429 (comment), which proposes making display animatable, to aid in creating "transition-out" animations.
This issue proposes:
- Adding an
inertproperty to CSS, and explaining the inert HTML attribute on top of that. - Making elements that are animating to
display: noneinert for the duration of the animation.
Let's say the JavaScript developer on a project creates a dialog/form, and when the form is submitted, the form is hidden via display: none, and the result of the form is used somehow in the app.
Then, at some later point, the CSS developer adds a transition which extends the interactive life of the element beyond what the JavaScript developer expected (the JavaScript developer and CSS developer may be the same person, but their mindset may be different when working with styles vs script).
This can be done already today, by overriding the default display: none on <dialog> elements (https://jsbin.com/xumitir/edit?html,css,js,output), but animating display: none, as proposed in #6429 (comment), creates an even more attractive, less-hacky way to do this.
By doing this, the CSS developer has created a significant change to the behaviour of the app. The user can now provide more than one submission to the form, since its lifetime in the app has been extended. This user action might be intentional (clicking the 'wrong' thing, then quickly clicking the right thing) or unintentional (double clicking).
Additionally, the element exists for longer in the accessibility tree, even though the intention is that it's 'gone'. This would result in unexpected behaviour for screen reader users.
These issues wasn't a possibility when the JavaScript developer created the form, so it's possible that these new interactions will be badly handled. The solution is to cater for interactions with the form beyond its previous lifecycle, or to prevent further interactions and AT visibility of the form using inert.
I think this is worth thinking about for two reasons:
- It's difficult to catch bugs resulting from this in development. My experience is developers rarely correctly cater for the extended lifetime of interactive elements during transitions-away.
- The issue is introduced by CSS, and the only way to fix it is in JS (
pointer-events: noneis an incomplete fix).
Potential solutions:
Education
We tell developers about this problem, and how to solve it in JavaScript. However, I have low confidence that we'd reach everyone, and even when it comes to folks we'd reach, would they remember to avoid these bugs?
Allow inert to be set in CSS
.hide {
transition: opacity 200ms, display 200ms;
display: none;
opacity: 0;
inert: yes;
}The current HTML inert attribute could be explained by a UA style:
[inert] {
inert: yes;
}I know there was opposition to this in the past, since it relates to behaviour rather than style, but it feels like display: none and particularly transitions on display: none already have a significant impact on behaviour. Showing an element changes the behaviour of the page, and if that's done in CSS, it seems reasonable to be able to express modality via CSS.
Open question: Should it be possible for a child of an inert element to become un-inert? This is possible with pointer-events.
This means that the interactivity issue created by CSS can be solved with CSS. But, it requires the developer to remember to set it, so:
Make elements transitioning to display:none inert by default
.hide {
transition: opacity 200ms, display 200ms;
display: none;
opacity: 0;
}During the transition above, inert could behave as yes. This would avoid the situation described at the start of this post, where the CSS developer introduced a behaviour the JS developer hadn't catered for.
If the developer wants the element to be interactive during the transition, they can override this default:
.hide {
transition: opacity 200ms, display 200ms;
display: none;
opacity: 0;
inert: no;
}
Activity
Loirooriol commentedon Feb 1, 2023
For reference, #7021 rejected exposing inertness as a CSS property.
jakearchibald commentedon Feb 1, 2023
"Will not add an inertness property for now.", so I guess I'm asking "…how about now?" 😁
cc @emilio @annevk, in case the above is compelling enough for them to change their mind.
josepharhar commentedon Feb 6, 2023
Is there a way to express this with a user-agent style or something?
If this isn't an important use case, then could we just make dialogs and popovers inert while transitioning to display:none without adding a new CSS property for inert?
chrishtr commentedon Feb 7, 2023
Re
inert: for reference, it was last discussed in issue #7021, and the reasons it was not implemented in CSS were:inertattribute's use casesHowever, the discussion in the issue indicated it wouldn't be very hard for the existing browser engines to add a CSS version (and in fact they use cascade / CSS infrastructure under the hood to implement the attribute already).
I'm not sure there is a simple way to express this. If there is, it would be nice to help authors avoid exit animation bugs.
One option could be to make all top layer elements inert during a transition in or out of the top layer (and spec it along with the proposed top-layer property, see #8189). And then add
inertto allow developers to opt into inert during other animations.Rip out all of the beautiful bespoke Popover animation stuff
nt1m commentedon Feb 7, 2023
How inert currently works corresponds roughly to this, so it's not as simple as @jakearchibald mentions. This is what allows modal dialogs to be interactive while the whole document is inert.
I'm reluctant to make this a CSS property since it limits what functionality we could apply to the inert attribute, since it'd be constrained by the CSS cascade.
nt1m commentedon Feb 7, 2023
(to be clear none of these UA styles currently exist in WebKit, they're expressed from style adjuster: https://searchfox.org/wubkat/rev/90549aec61bacbaee7383e1fb2623cf34edc9273/Source/WebCore/style/StyleAdjuster.cpp#569-581)
jakearchibald commentedon Feb 7, 2023
@flackr you had some thoughts around this, but I can't remember what they were
Rip out all of the beautiful bespoke Popover animation stuff
davwheat commentedon Feb 12, 2023
If this were to be added, it would be helpful to have a pseudoclass (
:inert, I assume?) for this to allow styles that currently select[inert]to be updated to handle both the HTML attribute and CSS property.Loirooriol commentedon Feb 13, 2023
We can have either an
:inertselector or aninertproperty, but not both. Or if we have both,:inertshouldn't take theinertproperty into account, since otherwise it would be circular::not(:inert) { inert: yes }.Rip out all of the beautiful bespoke Popover animation stuff
Rip out all of the beautiful bespoke Popover animation stuff
25 remaining items
Bug 1822742 [wpt PR 39023] - Make animations to display:none also app…
Make animations to display:none also apply inert
kizu commentedon Jun 15, 2023
I want to bring an issue I encountered while playing with the
displaytransition.The issue is: the inert behavior makes it impossible to implement an affordance period for tooltips on hover. Here is a CodePen that demonstrated the issue following issue — https://codepen.io/kizu/pen/rNQBvKm?editors=1100
Note: it seems that there could've been some change in Chrome Canary that broke the
displaytransitions in one of the latest build, so I couldn't reproduce them at all in the above CodePen or in other demos, so here is a screen recording showing the behavior when it was working:A.screen.recording.of.the.CodePen.in.action_.we.re.able.to.hover.out.of.the.element.with.a.transition.in.progress.when.it.is.an.element.with.visibility.transition.but.are.not.able.to.do.so.for.an.element.with.a.display.transition.mp4
The way developers usually apply the additional affordance for tooltips on hover is by adding an additional delay before the actual animation duration, allowing the following things:
These are in line with the https://www.w3.org/WAI/WCAG21/Understanding/content-on-hover-or-focus.html, both for the “Hoverable” and “Persistent” success criteria.
The problem right now is that the inert (and
pointer-events: none— I'm not sure if the “inert” includes it?) behavior kicks in right away when the element gets thedisplay: none, making the method of using thedelayuseless, as it becomes not possible to return the cursor to the tooltip.Proposed solutions:
inertandpointer-events: noneduring theduration, but not during thedelaywhen transitioning thedisplaytonone.inertbehavior as described in the issue, but still allowpointer-eventsboth for thedurationand thedelay(this would make the usage for tooltips in line with how transition forvisibilityworks).inert(and, if necessarypoiner-events) during the transition, similar to how we can control the top layer transition viaoverlay— I think this is a very similar case, and exposing the control for theinertonly as a part of a transition seems like an ok idea?flackr commentedon Jun 16, 2023
inert forces the browser to act as if we have
pointer-events: nonecurrently per the html spec. This behavior was discussed in #6685.Adding some thoughts to the different proposals:
Currently the way that we make the node inert is by determining that the base style (i.e. style without animations) is
display: none. This would require more complicated logic. E.g. if the base style isdisplay: noneand at least one animation animating display is in the active phase?I'm not sure I understand what you mean by "allow pointer-events"? Do you mean that the node would be inert but still hittable? I think this may be similar to my preferred behavior for inert #6685 (comment) but we would need to flesh out the details about how we still ensure that the elements within will not be interacted with.
I think there's two options here:
kizu commentedon Jun 16, 2023
Yes! I think, similar to the way
disabledworks on the buttons. Though, I wish we could control this on the disabled buttons as well, as there are cases when we want it to be disabled, but still catch some events (usually when we want to give some tooltip to a disabled button to hint over why is it disabled, or to track clicks on it, to see if the state is not conveyed well enough), which could be a good case for being able to controlinertfrom CSS (in some limited ways).I think both options can be good, but I'm afraid that exposing inertness is a much risky change overall, and those two could both exist at the same time; meaning if we allow transitioning inertness first, then if we'd later add an ability to control it more freely, it would be just an extension of the existing functionality.
nt1m commentedon Jun 16, 2023
I do want to remind why I think exposing inertness to CSS is a bad idea:
nt1m commentedon Jun 16, 2023
I'd be open to tweaking the pointer events model, but it's work that is unlikely going to get done in implementations given the low gain from it
Bug 1822742 [wpt PR 39023] - Make animations to display:none also app…
SebastianZ commentedon Nov 21, 2025
@josepharhar With this WPT in place, I think we can remove the Needs Testcase (WPT) label, right?
Sebastian
josepharhar commentedon Nov 21, 2025
Yes, I think we can remove the needs test label