-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Correct note on tabindexed elements and click event #1952
Correct note on tabindexed elements and click event #1952
Conversation
It appears this is an oversight/typo, but: non-interactive elements that are forced to be focusable with `tabindex` do NOT fire `click` when user presses ENTER. xref w3c/html#637
The note is simply explaining the requirement above. It does appear implementations do not implement this: http://software.hixie.ch/utilities/js/live-dom-viewer/saved/4600, but I think they should unless there's a reason they cannot. (Maybe a compatibility issue at this point?) The idea here is making it easier to write accessible code (and emulate behavior of built-in elements with activation behavior). |
Ah so "an activation behavior that does nothing" is supposed to mean that the It appears that most (all?) browsers (IE, Edge, Firefox, Chrome) don't fire |
The main potential problem I see is that if we start firing click events in addition to the keyboard events, the developer-written controls get activated twice. @dtapuska @smaug---- thoughts? (I believe this change followed from some work I did at Opera, but I guess tests never got written and nobody else picked up on it. Yet another good reason to land tests with changes / file browser bugs.) |
indeed. you'd get a repeat of the "touch events fire compatibility mouse events" dilemma, to an extent. |
I agree starting to fire click events more often feels rather risky. But I do like what the spec has. Unfortunately making such change is rather difficult: how to detect whether websites would be broken if browsers started to follow the spec here. |
sorry to labour to point, but relating still to the "The note is simply explaining the requirement above": does "an activation behavior that does nothing" mean that nothing happens if i press enter, or does it mean that |
@patrickhlauke apologies for not explaining. There's another section called "Activation" that has the following requirement:
So this doesn't strictly require Enter to be that key, since we generally do not make such specific requirements, but that would be the expected one (also used for activation of But it does require that an element that has activation behavior (even if that did itself does nothing) can be activated somehow (which happens through dispatch of the click event and corresponding language in the DOM Standard that triggers on that event and runs the activation behavior). |
Overall I think we should align with implementations here instead of hoping they will change. I think it would be a major compat worry and unless we have implementers actively excited about changing in the near future we should align. If I am understanding correctly, that would mean updating the note, as this PR does, but we also need to make sure the normative requirements align with the note. I think that would mean simply removing
Then such elements like the div in Anne's example would not have activation behavior, and thus would not cause "The user agent should allow the user to manually trigger elements that have an activation behavior" to apply to them. I guess the note would also be updated a bit to no longer say "This means that". |
Looking at the Chrome code we do exactly as the spec currently reads. See https://cs.chromium.org/chromium/src/third_party/WebKit/Source/core/html/HTMLElement.cpp?sq=package:chromium&rcl=1477308281&l=1129 but I don't know why in practice it doesn't fire for Patrick's example. I'll try to debug it tomorrow. |
@domenic if we cannot make it work I think we should strongly consider introducing a new feature, "activatable" or some such, to provide developers with the same convenience that built-in elements already have. Perhaps as an extension of custom elements or just something generic. Requiring non built-ins to account for all the possible ways in which something may be activated (especially over longer periods of time as UX evolves) is way bad. |
Yeah, I think this would be a plausible addition to the custom elements wishlist, along with many other activation/accessibility/etc. features. |
@dtapuska any updates? |
It is only dispatched when spatial navigation is enabled. It was landed first here: |
Fascinating. I cannot find anything on how to enable spatial navigation in Chrome, but some Googling shows it might be enable-able in Opera? I'm not sure what we should do with this exactly. Maybe we should say something like
Then we'd update the note in @patrickhlauke's original PR to talk about firing the click event in this mode only. Or, we could just remove it entirely, and leave this spatial navigation mode as some sort of outside-the-spec enhancement? @smaug----, do you know if Firefox has any mode like this? Maybe when a11y technology is enabled? |
|
Right, I meant for users :) |
that would get my vote. i understand the desire that UAs should simplify developers' life by triggering But I would like to see the current reality reflected in the spec. At a stretch, perhaps add a "User agents may provide a mode..." extra clause, just to open up the possibility of it happening (and to reflect spatnav scenarios)? |
Presto-based Opera (i.e. up until v12) had spatial navigation as a user setting ( |
Other than through a feature called “spatial navigation”, currently not enabled by default in any shipping browser, this behavior is not implemented and at this point it’s highly likely shipping it would break compatibility with deployed content as discussed in #1952. Removing it to reflect reality, but as we expand the features of custom elements, exposing “activation behavior” somehow should be high on the list as the effective default is detrimental to keyboard-only users. Closes #1952.
Created a PR to remove this and tried to include my rationale in the commit message there. |
There is http://searchfox.org/mozilla-central/source/toolkit/modules/SpatialNavigation.jsm and |
Other than through a feature called “spatial navigation”, currently not enabled by default in any shipping browser, this behavior is not implemented and at this point it’s highly likely shipping it would break compatibility with deployed content as discussed in #1952. Removing it to reflect reality, but as we expand the features of custom elements, exposing “activation behavior” somehow should be high on the list as the effective default is detrimental to keyboard-only users. Closes #1952.
Other than through a feature called “spatial navigation”, currently not enabled by default in any shipping browser, this behavior is not implemented and at this point it’s highly likely shipping it would break compatibility with deployed content as discussed in whatwg#1952. Removing it to reflect reality, but as we expand the features of custom elements, exposing “activation behavior” somehow should be high on the list as the effective default is detrimental to keyboard-only users. Closes whatwg#1952.
It appears this is an oversight/typo, but: non-interactive elements that
are forced to be focusable with
tabindex
do NOT fireclick
when userpresses ENTER. xref w3c/html#637