-
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
:active
pseudo-class specification doesn't account for children/labels of disabled form elements
#6635
Comments
cc @whatwg/css @whatwg/forms |
Hmm, but you can pretty much out an "activatable" element inside a disabled button, think of a help link or something. So going through the parent chain doesn't work unless I'm missing something. Special-casing disabled + :active here is not great, IMO. Disabled elements do match :hover for example, why would they not match :active? |
Because the spec clearly states:
Logically it makes no sense that a disabled element can be activated, it's disabled. If you want to explain why something is disabled shouldn't it be external to the disabled element, especially if it requires interactivity? |
"Activation behavior" (which is basically the click event) does have some special cases around disabled elements, see also #1576. Now whether that should be tied to cc @saschanaz |
The Since it's already not very consistent with other |
@whatwg/a11y thoughts? |
naively, as an author i'd expect that something marked as if looking at to aid authors in building their conceptual model of what as an aside, from the JS side, the weird "clicking the
you shouldn't really have an actionable element wrapped inside a disabled element - like a proper from an accessibility point of view, there's no SC directly in WCAG that speaks to the need/behaviour of |
:active
pseudo-class specification doesn't account for children of disabled form elements:active
pseudo-class specification doesn't account for children/labels of disabled form elements
Although what @saschanaz said seemed counter-intuitive to me initially, the longer I think about it - the more it made sense from an implementation perspective. It allows easier visual consistency across browsers (less specialized rule logic) compared to adding additional corrective spec for conditionally triggering Chromium user agent stylesheet would need revision to ensure no visual change happens for activated disabled form elements once this is implemented. Seems to be the path of least resistance (the JS aside on the other hand...). |
What would be the theoretical next step? Does it become a topic of discussion at an upcoming meeting of sorts? Would like to learn more about the process here :) |
I added The UA stylesheet is easy to update. The web legacy using Are there known bugs or complaints about Firefox's behavior? |
anecdotally, on Bootstrap we've had to add I have no doubt that authors hitting the weird behavior in their own projects have hacked around enough to suppress this in similar ways. despite this, it'd be more sustainable to fix this at the root ... |
Safari seems to behave like Firefox: clicking the disabled button matches |
I think the root of the issue here is that you could imagine two meanings of "active":
My reading is that the spec is trying to go for (2), but doing it poorly, and that hasn't been implemented very well. Thus all the text about disabled, and talking about having activation behavior instead of just keying off of user intent to activate. @emilio points out that (1) is much more consistent with other similar pseudo-classes, such as I agree with @patrickhlauke that getting something consistent, which developers can build a good mental model around, is the highest priority here. So I support aligning the spec with 2/3 browsers (Safari and Firefox), around definition (1). I hope we can update Chrome to match. Separately, it sounds like there might be interest in authors in telling whether something can be successfully activated, in the sense of (2). For this I'd suggest a separate proposal, e.g. a pseudo-class |
What’s the use case for 1? I can’t think of any use case for active that isn’t exclusively 2. |
It's pretty common to want to style things that are clicked, even if clicking them does nothing (besides change the style). |
“that are clicked” can refer to the click event, sure, but otherwise it would mean “things that are successfully clicked”, which a disabled button can never be. (and I’m skeptical anyone wants to use the active pseudo class to target unclickable things) |
It's pretty common to have active state on list items, spans, divs, or other things that can potentially receive mousedown events that get handled via JS. E.g., https://material.io/components/cards has an example where the "Elevated" and "Outlined" tabs are just Whether those should conceptually be Plus, So unless we're discussing to more fundamentally change how |
I found an interesting other non-interop: https://jsbin.com/luwicesuwu/1/edit?html,output My question was: the spec currently has a hard-coded list of elements which could match My test case was an (Unfortunately I went into another lockdown here in NYC and left my testing Mac at the office, sigh...) I like Chrome's behavior more, both in how it makes the spec simpler and in how it seems good to give keyboard users the same experience as mouse users for all activatable controls, not just a hard-coded list. What do others think? |
This matches Gecko and WebKit. The disabled condition was added to the spec in 9985973 but not implemented uniformly. As discussed in #6635, it doesn't work very well and is inconsistent with other similar pseudo-classes, like :hover. This also removes the consideration of <link> elements with href="" attributes, since they no longer have activation behavior as of 1e0ee7f. And it updates the definitions of both :active and :hover to be based on the latest Selectors spec, which notably includes the ancestor condition over the flat tree at the CSS layer, instead of having HTML handle that. There remains some lack of interop around elements such as <input type=radio> which have activation behavior but are not on the list of elements for which "in a formal activation state" is considered. #6635 stays open to track that case.
This matches Gecko and WebKit. The disabled condition was added to the spec in 9985973 but not implemented uniformly. As discussed in #6635, it doesn't work very well and is inconsistent with other similar pseudo-classes, like :hover. This also removes the consideration of <link> elements with href="" attributes, since they no longer have activation behavior as of 1e0ee7f. And it updates the definitions of both :active and :hover to be based on the latest Selectors spec, which notably includes the ancestor condition over the flat tree at the CSS layer, instead of having HTML handle that. There remains some lack of interop around elements such as <input type=radio> which have activation behavior but are not on the list of elements for which "in a formal activation state" is considered. #6635 stays open to track that case.
This matches Gecko and WebKit. The disabled condition was added to the spec in 9985973 but not implemented uniformly. As discussed in #6635, it doesn't work very well and is inconsistent with other similar pseudo-classes, like :hover. This also removes the consideration of <link> elements with href="" attributes, since they no longer have activation behavior as of 1e0ee7f. And it updates the definitions of both :active and :hover to be based on the latest Selectors spec, which notably includes the ancestor condition over the flat tree at the CSS layer, instead of having HTML handle that. There remains some lack of interop around elements such as <input type=radio> which have activation behavior but are not on the list of elements for which "in a formal activation state" is considered. #6635 stays open to track that case.
Without knowing if there's any particular history driving the current behavior, yeah, that seems to make sense to me. |
@domenic just saw the triage meeting minutes, I haven't been available to revise the behaviour demonstration that was discussed at the previous triage meeting - life has been getting in the way. Thanks for keeping it alive. Linking to PR for reference: #7465 - will review and join discussion if I find the time ⌚ |
I've decided to split the issue discussed in #6635 (comment) into a separate issue, #7578. For this issue, #7465 remains the relevant PR. That is ready to merge but is missing web platform tests before we can do so. When we merge it it will close this particular issue. |
This removes the disabled condition for :active, matching Gecko and WebKit. The condition was added to the spec in 9985973 but not implemented uniformly. As discussed in #6635, it doesn't work very well and is inconsistent with other similar pseudo-classes, like :hover. This also removes the consideration of <link> elements with href="" attributes for :active, since they no longer have activation behavior as of 1e0ee7f. Finally, this updates the definitions of both :active and :hover to be based on the latest Selectors spec, which notably includes the ancestor condition over the flat tree at the CSS layer, instead of having HTML handle that. This required splitting up "being activated" and "matches :active", as well as "designated" and "matches :hover". Closes #6635, although note that there remain other interop issues with :active, tracked in #7578.
We are changing this behavior because other browsers don't have disabled conditioning for :active and because it will become more consistent with other pseudo classes: whatwg/html#6635 (comment) Fixed: 1287171 Change-Id: Idab2abbbc94cc73fac70e34ef391c5d63518d569
We are changing this behavior because other browsers don't have disabled conditioning for :active and because it will become more consistent with other pseudo classes: whatwg/html#6635 (comment) Fixed: 1287171 Change-Id: Idab2abbbc94cc73fac70e34ef391c5d63518d569 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3453424 Commit-Queue: Joey Arhar <jarhar@chromium.org> Reviewed-by: Mason Freed <masonf@chromium.org> Cr-Commit-Position: refs/heads/main@{#970008}
We are changing this behavior because other browsers don't have disabled conditioning for :active and because it will become more consistent with other pseudo classes: whatwg/html#6635 (comment) Fixed: 1287171 Change-Id: Idab2abbbc94cc73fac70e34ef391c5d63518d569 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3453424 Commit-Queue: Joey Arhar <jarhar@chromium.org> Reviewed-by: Mason Freed <masonf@chromium.org> Cr-Commit-Position: refs/heads/main@{#970008}
We are changing this behavior because other browsers don't have disabled conditioning for :active and because it will become more consistent with other pseudo classes: whatwg/html#6635 (comment) Fixed: 1287171 Change-Id: Idab2abbbc94cc73fac70e34ef391c5d63518d569 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3453424 Commit-Queue: Joey Arhar <jarhar@chromium.org> Reviewed-by: Mason Freed <masonf@chromium.org> Cr-Commit-Position: refs/heads/main@{#970008}
We are changing this behavior because other browsers don't have disabled conditioning for :active and because it will become more consistent with other pseudo classes: whatwg/html#6635 (comment) Fixed: 1287171 Change-Id: Idab2abbbc94cc73fac70e34ef391c5d63518d569 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3453424 Commit-Queue: Joey Arhar <jarhar@chromium.org> Reviewed-by: Mason Freed <masonf@chromium.org> Cr-Commit-Position: refs/heads/main@{#970008}
…atching, a=testonly Automatic update from web-platform-tests Remove disabled condition from :active matching We are changing this behavior because other browsers don't have disabled conditioning for :active and because it will become more consistent with other pseudo classes: whatwg/html#6635 (comment) Fixed: 1287171 Change-Id: Idab2abbbc94cc73fac70e34ef391c5d63518d569 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3453424 Commit-Queue: Joey Arhar <jarhar@chromium.org> Reviewed-by: Mason Freed <masonf@chromium.org> Cr-Commit-Position: refs/heads/main@{#970008} -- wpt-commits: e3cb675e1b16603aa51051de59cfd4056d89a04d wpt-pr: 32804
We are changing this behavior because other browsers don't have disabled conditioning for :active and because it will become more consistent with other pseudo classes: whatwg/html#6635 (comment) Fixed: 1287171 Change-Id: Idab2abbbc94cc73fac70e34ef391c5d63518d569 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3453424 Commit-Queue: Joey Arhar <jarhar@chromium.org> Reviewed-by: Mason Freed <masonf@chromium.org> Cr-Commit-Position: refs/heads/main@{#970008}
…atching, a=testonly Automatic update from web-platform-tests Remove disabled condition from :active matching We are changing this behavior because other browsers don't have disabled conditioning for :active and because it will become more consistent with other pseudo classes: whatwg/html#6635 (comment) Fixed: 1287171 Change-Id: Idab2abbbc94cc73fac70e34ef391c5d63518d569 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3453424 Commit-Queue: Joey Arhar <jarhar@chromium.org> Reviewed-by: Mason Freed <masonf@chromium.org> Cr-Commit-Position: refs/heads/main@{#970008} -- wpt-commits: e3cb675e1b16603aa51051de59cfd4056d89a04d wpt-pr: 32804
…atching, a=testonly Automatic update from web-platform-tests Remove disabled condition from :active matching We are changing this behavior because other browsers don't have disabled conditioning for :active and because it will become more consistent with other pseudo classes: whatwg/html#6635 (comment) Fixed: 1287171 Change-Id: Idab2abbbc94cc73fac70e34ef391c5d63518d569 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3453424 Commit-Queue: Joey Arhar <jarhar@chromium.org> Reviewed-by: Mason Freed <masonf@chromium.org> Cr-Commit-Position: refs/heads/main@{#970008} -- wpt-commits: e3cb675e1b16603aa51051de59cfd4056d89a04d wpt-pr: 32804
…atching, a=testonly Automatic update from web-platform-tests Remove disabled condition from :active matching We are changing this behavior because other browsers don't have disabled conditioning for :active and because it will become more consistent with other pseudo classes: whatwg/html#6635 (comment) Fixed: 1287171 Change-Id: Idab2abbbc94cc73fac70e34ef391c5d63518d569 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3453424 Commit-Queue: Joey Arhar <jarhar@chromium.org> Reviewed-by: Mason Freed <masonf@chromium.org> Cr-Commit-Position: refs/heads/main@{#970008} -- wpt-commits: e3cb675e1b16603aa51051de59cfd4056d89a04d wpt-pr: 32804
This removes the disabled condition for :active, matching Gecko and WebKit. The condition was added to the spec in 9985973 but not implemented uniformly. As discussed in whatwg#6635, it doesn't work very well and is inconsistent with other similar pseudo-classes, like :hover. This also removes the consideration of <link> elements with href="" attributes for :active, since they no longer have activation behavior as of 1e0ee7f. Finally, this updates the definitions of both :active and :hover to be based on the latest Selectors spec, which notably includes the ancestor condition over the flat tree at the CSS layer, instead of having HTML handle that. This required splitting up "being activated" and "matches :active", as well as "designated" and "matches :hover". Closes whatwg#6635, although note that there remain other interop issues with :active, tracked in whatwg#7578.
We are changing this behavior because other browsers don't have disabled conditioning for :active and because it will become more consistent with other pseudo classes: whatwg/html#6635 (comment) Fixed: 1287171 Change-Id: Idab2abbbc94cc73fac70e34ef391c5d63518d569 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3453424 Commit-Queue: Joey Arhar <jarhar@chromium.org> Reviewed-by: Mason Freed <masonf@chromium.org> Cr-Commit-Position: refs/heads/main@{#970008} NOKEYCHECK=True GitOrigin-RevId: ed8595a55c008ac96404f2d95408f59c9a3833b6
tl;dr
:active
is being triggered by/within disabled form elements inconsistently (browser dependent). Specification doesn't account for children/labels of disabled form elements edge case.There are many situations where child elements are added to buttons, icons as a simple example. When the input, button or textarea are given the
disabled
attribute things become weird.Demonstration of behaviour: https://codepen.io/alystair/pen/gOgJZaq?editors=1101
button
only activates:active
when clicking children (follows current spec).input
andtextarea
activates:active
(not following spec):active
triggers in all instances (not following spec)Current workaround: add
pointer-events:none
to element (and it's children) withdisabled
attribute. Less trivial for non-wrappinglabel
elements.Relevant spec: https://html.spec.whatwg.org/multipage/semantics-other.html#selector-active
...
Specification should be revised to ensure:
label
does not havedisabled
state.Somewhat related (and I don't mean to sidetrack):
This works as intended when the event listener is attached to the element itself. However when the event handler is attached to a parent, children of disabled elements 'leak' through - is this intentional?
The text was updated successfully, but these errors were encountered: