Skip to content
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 and activating via the keyboard #7578

Open
domenic opened this issue Feb 3, 2022 · 4 comments
Open

:active and activating via the keyboard #7578

domenic opened this issue Feb 3, 2022 · 4 comments
Assignees
Labels
interop Implementations are not interoperable with each other topic: style

Comments

@domenic
Copy link
Member

domenic commented Feb 3, 2022

Spinning off from #6635 (comment) . Question: when does :active match? #7465 takes care of some of the current interop problems, but isn't merged yet due to lack of tests; let's use https://whatpr.org/html/7465/semantics-other.html#selector-active as the working definition for this issue.

https://jsbin.com/cifugag/1/edit?html,output shows that the spec does not match either Firefox or Chrome:

  • Spec: pressing spacebar on the <input type=radio> must not match :active, since it's not on the special list of elements for which "in a formal activation state" applies. Pressing spacebar on the <button> must match :active, since it is on that list.

  • Firefox: pressing spacebar never causes any elements to match :active. Only the "being actively pointed at" clause applies.

  • Chrome: pressing spacebar causes both the <input type=radio> and the <button> to match :active. It does not cause the <div> to match :active. Chrome appears to be applying the "in a formal activation state" definition to any element with activation behavior, which includes radio buttons but not divs.

  • Safari: ???

I personally think the Chrome behavior makes the most sense (as it gives keyboard users and mouse users the same experience). The next step is to test Safari to see if that can give us any input.

@domenic
Copy link
Member Author

domenic commented Feb 10, 2022

The "normal a" link in https://output.jsbin.com/hujeguhivo throws a wrench into this ontology. Apparently keydown on the Enter key will navigate a link, and will not cause that link to match :active. So there's no "in a formal activation state" for <a> elements, really. Fun...

domenic added a commit that referenced this issue Feb 10, 2022
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.
mfreed7 pushed a commit to mfreed7/html that referenced this issue Jun 3, 2022
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.
@emilio emilio added the agenda+ To be discussed at a triage meeting label Nov 13, 2023
@emilio
Copy link
Contributor

emilio commented Nov 13, 2023

Ah, I was going to file an issue about this stuff because @dshin-moz and I were looking at some :has() interop-2023 failures, and found yours, @domenic :)

Other things that are funny about this:

  • On WebKit and Blink, :active on buttons doesn't propagate the active state through the ancestor chain. test case
  • On WebKit and Blink, if you preventDefault() the keyup event, the :active state persists. test case
  • The timing at which the flag is set and cleared is not interoperable either, even on click. test case. @mfreed7 do you know when stuff is set / unset in Blink?

It'd be nice to get better spec text for how this is supposed to work... cc @smaug----

@mfreed7
Copy link
Collaborator

mfreed7 commented Nov 13, 2023

  • The timing at which the flag is set and cleared is not interoperable either, even on click. test case. @mfreed7 do you know when stuff is set / unset in Blink?

The behavior of :active is definitely odd and could use some attention. I know Blink has several bugs in this area. The code is this one, calls to which are sprinkled everywhere.

moz-wptsync-bot pushed a commit to web-platform-tests/wpt that referenced this issue Nov 13, 2023
…mpleted.

Previously, the test relied upon event listener to listen to related events:
e.g. `mousedown` event on `Actions().pointerDown()`. However, as comments in
whatwg/html#7578 indicate when `:active` matches
does not seem to be interoperable across browsers with different inputs.
Instead rely on the action sequence being completed, as done with a simliar
test, `html/semantics/selectors/pseudo-classes/active-disabled.html`.

Differential Revision: https://phabricator.services.mozilla.com/D193463

bugzilla-url: https://bugzilla.mozilla.org/show_bug.cgi?id=1759031
gecko-commit: ab075d8118aecde5cf88872225b85effcfffbacb
gecko-reviewers: emilio
moz-v2v-gh pushed a commit to mozilla/gecko-dev that referenced this issue Nov 14, 2023
…ions being completed. r=emilio

Previously, the test relied upon event listener to listen to related events:
e.g. `mousedown` event on `Actions().pointerDown()`. However, as comments in
whatwg/html#7578 indicate when `:active` matches
does not seem to be interoperable across browsers with different inputs.
Instead rely on the action sequence being completed, as done with a simliar
test, `html/semantics/selectors/pseudo-classes/active-disabled.html`.

Differential Revision: https://phabricator.services.mozilla.com/D193463
moz-wptsync-bot pushed a commit to web-platform-tests/wpt that referenced this issue Nov 14, 2023
…mpleted.

Previously, the test relied upon event listener to listen to related events:
e.g. `mousedown` event on `Actions().pointerDown()`. However, as comments in
whatwg/html#7578 indicate when `:active` matches
does not seem to be interoperable across browsers with different inputs.
Instead rely on the action sequence being completed, as done with a simliar
test, `html/semantics/selectors/pseudo-classes/active-disabled.html`.

Differential Revision: https://phabricator.services.mozilla.com/D193463

bugzilla-url: https://bugzilla.mozilla.org/show_bug.cgi?id=1759031
gecko-commit: adc6a6f51dfa6facc44c1afe4bf3455c3bf32fad
gecko-reviewers: emilio
moz-v2v-gh pushed a commit to mozilla/gecko-dev that referenced this issue Nov 15, 2023
…ions being completed. r=emilio

Previously, the test relied upon event listener to listen to related events:
e.g. `mousedown` event on `Actions().pointerDown()`. However, as comments in
whatwg/html#7578 indicate when `:active` matches
does not seem to be interoperable across browsers with different inputs.
Instead rely on the action sequence being completed, as done with a simliar
test, `html/semantics/selectors/pseudo-classes/active-disabled.html`.

Differential Revision: https://phabricator.services.mozilla.com/D193463
vinnydiehl pushed a commit to vinnydiehl/mozilla-unified that referenced this issue Nov 15, 2023
…ions being completed. r=emilio

Previously, the test relied upon event listener to listen to related events:
e.g. `mousedown` event on `Actions().pointerDown()`. However, as comments in
whatwg/html#7578 indicate when `:active` matches
does not seem to be interoperable across browsers with different inputs.
Instead rely on the action sequence being completed, as done with a simliar
test, `html/semantics/selectors/pseudo-classes/active-disabled.html`.

Differential Revision: https://phabricator.services.mozilla.com/D193463
moz-wptsync-bot pushed a commit to web-platform-tests/wpt that referenced this issue Nov 15, 2023
…mpleted.

Previously, the test relied upon event listener to listen to related events:
e.g. `mousedown` event on `Actions().pointerDown()`. However, as comments in
whatwg/html#7578 indicate when `:active` matches
does not seem to be interoperable across browsers with different inputs.
Instead rely on the action sequence being completed, as done with a simliar
test, `html/semantics/selectors/pseudo-classes/active-disabled.html`.

Differential Revision: https://phabricator.services.mozilla.com/D193463

bugzilla-url: https://bugzilla.mozilla.org/show_bug.cgi?id=1759031
gecko-commit: adc6a6f51dfa6facc44c1afe4bf3455c3bf32fad
gecko-reviewers: emilio
gecko-dev-updater pushed a commit to marco-c/gecko-dev-wordified-and-comments-removed that referenced this issue Nov 16, 2023
…ions being completed. r=emilio

Previously, the test relied upon event listener to listen to related events:
e.g. `mousedown` event on `Actions().pointerDown()`. However, as comments in
whatwg/html#7578 indicate when `:active` matches
does not seem to be interoperable across browsers with different inputs.
Instead rely on the action sequence being completed, as done with a simliar
test, `html/semantics/selectors/pseudo-classes/active-disabled.html`.

Differential Revision: https://phabricator.services.mozilla.com/D193463

UltraBlame original commit: ab075d8118aecde5cf88872225b85effcfffbacb
gecko-dev-updater pushed a commit to marco-c/gecko-dev-wordified-and-comments-removed that referenced this issue Nov 16, 2023
…ions being completed. r=emilio

Previously, the test relied upon event listener to listen to related events:
e.g. `mousedown` event on `Actions().pointerDown()`. However, as comments in
whatwg/html#7578 indicate when `:active` matches
does not seem to be interoperable across browsers with different inputs.
Instead rely on the action sequence being completed, as done with a simliar
test, `html/semantics/selectors/pseudo-classes/active-disabled.html`.

Differential Revision: https://phabricator.services.mozilla.com/D193463

UltraBlame original commit: adc6a6f51dfa6facc44c1afe4bf3455c3bf32fad
gecko-dev-updater pushed a commit to marco-c/gecko-dev-comments-removed that referenced this issue Nov 16, 2023
…ions being completed. r=emilio

Previously, the test relied upon event listener to listen to related events:
e.g. `mousedown` event on `Actions().pointerDown()`. However, as comments in
whatwg/html#7578 indicate when `:active` matches
does not seem to be interoperable across browsers with different inputs.
Instead rely on the action sequence being completed, as done with a simliar
test, `html/semantics/selectors/pseudo-classes/active-disabled.html`.

Differential Revision: https://phabricator.services.mozilla.com/D193463

UltraBlame original commit: ab075d8118aecde5cf88872225b85effcfffbacb
gecko-dev-updater pushed a commit to marco-c/gecko-dev-comments-removed that referenced this issue Nov 16, 2023
…ions being completed. r=emilio

Previously, the test relied upon event listener to listen to related events:
e.g. `mousedown` event on `Actions().pointerDown()`. However, as comments in
whatwg/html#7578 indicate when `:active` matches
does not seem to be interoperable across browsers with different inputs.
Instead rely on the action sequence being completed, as done with a simliar
test, `html/semantics/selectors/pseudo-classes/active-disabled.html`.

Differential Revision: https://phabricator.services.mozilla.com/D193463

UltraBlame original commit: adc6a6f51dfa6facc44c1afe4bf3455c3bf32fad
gecko-dev-updater pushed a commit to marco-c/gecko-dev-wordified that referenced this issue Nov 16, 2023
…ions being completed. r=emilio

Previously, the test relied upon event listener to listen to related events:
e.g. `mousedown` event on `Actions().pointerDown()`. However, as comments in
whatwg/html#7578 indicate when `:active` matches
does not seem to be interoperable across browsers with different inputs.
Instead rely on the action sequence being completed, as done with a simliar
test, `html/semantics/selectors/pseudo-classes/active-disabled.html`.

Differential Revision: https://phabricator.services.mozilla.com/D193463

UltraBlame original commit: ab075d8118aecde5cf88872225b85effcfffbacb
gecko-dev-updater pushed a commit to marco-c/gecko-dev-wordified that referenced this issue Nov 16, 2023
…ions being completed. r=emilio

Previously, the test relied upon event listener to listen to related events:
e.g. `mousedown` event on `Actions().pointerDown()`. However, as comments in
whatwg/html#7578 indicate when `:active` matches
does not seem to be interoperable across browsers with different inputs.
Instead rely on the action sequence being completed, as done with a simliar
test, `html/semantics/selectors/pseudo-classes/active-disabled.html`.

Differential Revision: https://phabricator.services.mozilla.com/D193463

UltraBlame original commit: adc6a6f51dfa6facc44c1afe4bf3455c3bf32fad
jamienicol pushed a commit to jamienicol/gecko that referenced this issue Nov 16, 2023
…ions being completed. r=emilio

Previously, the test relied upon event listener to listen to related events:
e.g. `mousedown` event on `Actions().pointerDown()`. However, as comments in
whatwg/html#7578 indicate when `:active` matches
does not seem to be interoperable across browsers with different inputs.
Instead rely on the action sequence being completed, as done with a simliar
test, `html/semantics/selectors/pseudo-classes/active-disabled.html`.

Differential Revision: https://phabricator.services.mozilla.com/D193463
@dbaron
Copy link
Member

dbaron commented Nov 30, 2023

A bunch of pointers to related things here:

  • I dug into the code in Blink that does this activation (as part of investigating nested interactive content inside of summary) and wrote up crbug.com/1361983 comment 5. (Also see related crbug.com/1469699.) I found that there are a bunch of elements where space and enter activation work differently. In Chrome the code for this exists in two different places (see the commit message in crrev.com/c/4673631). In Blink this applies to button, summary, permission (experimental), and some types (checkbox, radio, button types, temporal types with a chooser, color, and file) of input. I also found equivalent code in Gecko that appears to make the same space/enter difference, although it doesn't lead to the same summary bug, which makes me think at least parts of the difference in space/enter handling might not be possible to change for web compatibility reasons, although I could imagine making some incremental improvements. My initial reaction is that the space behavior is better for its :active behavior (supported for space activation but not enter activation) and its handling of key repetition (don't repeat), and the enter behavior (in Blink, although Gecko has some solution for this) is better for its interaction with nested text inputs (don't activate the outer element for key presses in the inner one). (But composing with other types of nested content might have different pluses/minuses, and we may want a better solution to those problems... but it's also a space where changing the behavior could be difficult given compatibility constraints.)
  • I do like the idea of making :active work for keyboard activation, and agree that it would make more sense if it works hierarchically like it does for the mouse. I'm not entirely sure how simultaneous keyboard and mouse activation should work but it feels like it might be possible for two different element hierarchies to be implemently :active (one from the keyboard and one from the mouse) although it might be hard to reach this state given focus behavior.
  • If we do standardize keyboard activation triggering :active, we should be careful about what events start and end the active state, make sure the behavior when focus changes between key down and key up is correct, and hopefully get reasonable behavior for key repetition.

@past past removed the agenda+ To be discussed at a triage meeting label Nov 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
interop Implementations are not interoperable with each other topic: style
Development

No branches or pull requests

5 participants