-
Notifications
You must be signed in to change notification settings - Fork 12
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
How to handle Space vs Enter for buttons #939
Comments
I believe @zepumph will bring this up in today's meeting. Some things that seem relevant to go over in that meeting include:
|
Our buttons respond to the Since we can't always listen to Having a good way to delay firing listeners on the |
@emily-phet said:
This would match how "fire on hold" typically works. Both the delay and interval should be configurable. Some PhET UI components have this feature, some do not. Sun push buttons do support this feature, see PushButtonModel: // fire-on-hold feature
fireOnHold: false,
fireOnHoldDelay: 400, // start to fire continuously after pressing for this long (milliseconds)
fireOnHoldInterval: 100, // fire continuously at this interval (milliseconds) |
@jessegreenberg said:
Why can't we? And why are we explicitly writing handlers that listener for |
Assistive devices can change which DOM events are sent, even for identical user interactions. For instance, press "enter" on a button without NVDA and |
Hmm... Then ComboBox will need to change - it's currently listening for Are |
The DOM events are determined by the role of the element that has focus. In ComboBox, focus is on an element with the ARIA role |
Here is a stack overflow I found that helps describe why the default browser behavior is the way it is |
Re the stackoverflow article... I see conjecture, but no authoritative reference. If we accept this hypothesis, which is in the response with the largest number of votes:
If the semantics of Enter are "accept", then why does it fire repeatedly when the button is held down? |
@jessegreenberg Thanks for the clarification. I didn't realize that you were referring exclusively to elements with role |
Here's something else that makes no sense to me, observed in the current implementation of ComboBox. If the combo box button has focus, pressing Enter pops up the listbox, and releasing Enter immediately pops down the listbox. Demonstrated in Molarity:
So by clicking Enter (which supposedly means "accept") the related events get sent to whatever UI component happens to have focus at the time. That Enter was meant for the button, and only the button. The listbox and its items shouldn't be receiving anything related to that user action. |
That is another problem, and also happens with I think we should create another issue to investigate this (#942). Working on the timing for firing buttons with the keyboard (probably in PressListener) will be continued in #931. Does everyone agree that this can be closed? |
@zepumph, @pixelzoom, @jessegreenberg, currently from phettest and using Safari on Mac OS (with or without a screen reader on), the button that pops up the the list of options is not operable with the Enter key, only the Space key. It's a Perhaps this article by Paul J. Adam from Deque on building accessible buttons will help us gain some understanding. It is important to note, however, that our implementation is a Note, we are using a real
Further down in the article, for native
The pattern that we adapted for the PhET Combobox if I am remembering correctly from the example of a Collapsible Drop Down List. Of course, we pop up rather than down. The short of it is that we need the Enter key to work on the Enter key should pop up the list and the list should stay visible with focus shown on the selected solute until Space, Enter or Esc are pressed. Arrow keys are used to move focus within the list of options. |
I think we can close this issue if we agree that we should be supporting both Space and Enter keys on buttons. |
Please re-assign to me as needed. |
Adding links to previous research in other issues I appreciate all the effort going into the PhET Combobox! |
@terracoda reported:
Thanks @terracoda. This specific issue with ComboBox is being tracked in phetsims/sun#447. A general solution is preferrable, and workaround in ComboBox is a last resort, and we've been deferring that issue until this more general issue is addressed. |
@terracoda said:
I DO think we're all in agreement that Enter and Space both need to be tracked. But this issue deals with how to support them both. Specifically, we need to address differences when Enter and Space fire, how and when events are delivered to the sim, |
In preparation for 3/3/19 conference call, I did a deeper dive into the ARIA references that @terracoda provide in #939 (comment), as well as the HTML5 specifications. I was looking for info relevant to this issue, especially ways that we might customize the ARIA
|
More about the The https://www.w3.org/TR/html5/webappapis.html#fire-a-click-event defines what a
https://www.w3.org/TR/html5/webappapis.html#firing-a-synthetic-mouse-event-named-e https://www.w3.org/TR/html5/editing.html#dom-htmlelement-click describes what happens when a click event is synthesized:
The steps involved in “run synthetic click activation steps” are defined in the Activation section of the spec, mentioned above and at https://www.w3.org/TR/html5/editing.html#activation. These steps appear to be customizable. Question: Do any of the Question: Can synthesis of the |
ARIA examples for The behavior of the "Mute" button here is interesting. If you tab to the Mute button, then press and hold the Space key, there is a brief delay, then the button activates (fires) repeatedly. This does not match the behavior that we've seen for the Space key - we've seen activation on keydown, with seemingly no way to accomplish fireOnHold. The links to source code are also interesting. In button.js, they add event listeners for Question: Why is the activation behavior different in this example? Is there something we can apply? (EDIT: See also the commits for example fixes in w3c/aria-practices#610.) |
Here's a bug report related to the difference between Enter and Space. It indicates that the button examples in #939 (comment) are buggy, and the ARIA design pattern is incompletely specified. The bug report is w3c/aria-practices#610:
I found this bug report by clicking the "Related Issues" link for the ARIA role=button examples at https://www.w3.org/TR/wai-aria-practices/examples/button/button.html. Note that this issue is in repository w3c/aria-practices (ARIA Practices). It was verified to be a bug, it was fixed, and the issue was closed on 10/12/2018. Edit: Note that this bug report is the first place where I've found evidence that the Enter and Space keys are expected to behave differently. |
Great investigation and questions @pixelzoom. And glad you found the latest version of the button examples. The first link was to a "WD" or "working draft". In the latest version, on the Mute toggle button, the Space key fires/is activated on release and the Enter key fires/activates repeatedly which seems more typical, though still unexplained by the standards documentation. @jessegreenberg and I investigated many types of button in our early investigations for BASE's custom "drag & gab" interaction, but for other reasons. We know a lot more now - both about users and about the HTML and ARIA specifications. Exploring how activation can be customized, understanding the fullest potential of the click event, and exploring further possibilities available through the Looking forward to our discussion. |
@jessegreenberg or @zepumph can you please summarize the discussion from Monday, and point out the next steps for this issue? Does it still need to be discussed at dev meeting? |
During discussion on 3/4/19 we reviewed why we are encountering this issue and potential solutions. We discussed how scenery/simulations would behave if we proceed with changes described in #945. No major concerns with this came up during the meeting. An alternative proposed during the meeting was to ignore "press and hold" and "fire on down" interaction for alternative input and just fire buttons on Here are the next steps: @pixelzoom identified a number of resources and questions in #939 (comment) #939 (comment) and #939 (comment), those should be reviewed before more work is done. After doing those things we can decide whether or not to proceed with #945. |
@jessegreenberg, I also shared with you, @pixelzoom and @zepumph comments from the WAI ARIA interest group which included a mark-up idea that we have not yet explored, nesting a
This mark-up could potentially be useful for the "press and hold" and "fire on down" buttons once we get them for alternative input. Just adding it, since it is related to the issue. |
Thanks for collecting resources and questions @pixelzoom. Some of this we have already considered but all I am reviewing the questions and links listed in #939 (comment), #939 (comment), #939 (comment) and #939 (comment)
Not to my knowledge. https://www.w3.org/TR/html5/editing.html#activation spec is for the user agent (browser), I don't see anything there usable by web developers.
The
+1 to the edit. But I also verified that
These are steps for the user agent. The fields available for web developers are listed in MouseEvent(because
It is mentioned in https://www.w3.org/TR/2016/WD-wai-aria-practices-1.1-20160317/examples/button/button.html# that
Yes, we could do that. We happen to know the author of that issue who is a member of the ARIA WG. Differences between enter and spacebar go beyond buttons and the web. For instance, checkboxes only activate with spacebar, they don't respond to enter. I just verified that was true in a native Windows app. |
Actually, I had forgotten that @terracoda already reached out to the ARIA group about this. https://lists.w3.org/Archives/Public/w3c-wai-ig/2019JanMar/0086.html |
No matter whata we do, somewhere in button code we will need to change the markup for the button so that it looks like <div role="application">
<button>BUTTON</button>
</div> If we don't go with #945, somewhere in button code we will also have to opt out of If we do this, it will make button code a little more complicated, keyboard use without a screen reader will generally not support PushButtonModel options. But we avoid doing something tricky and PhET specific for a11y in scenery. And we avoid adding differences in sim behavior when a screen reader is enabled vs disabled. I think we should just do that. This will also set us up for switching to #945 strategy if we need to later, but avoids trickiness for now. @zepumph can we talk at tomorrows dev meeting to finalize? |
Notes from 4/8/19 discussion: During discussion on 4/8/19, @samreid suggested that rather than having some of our buttons use use unique markup and input handling that we modify the user interface (both visual and PDOM) to support different modes of interaction. For instance, for the StepButton we could also have a "slow motion" button that changes the behavior of step to work better with single click activations. However, it is unclear how this would work because the step button will still respond to click events at the interval that the assistive device sends events to the browser. And modifying the UI will be more time intensive. By keeping our current system, we get the semantic button interaction that has been tested with users and we know works well. We don't have to change our input system for a11y or doing anything that is PhET specific. For specific buttons, we can support PushButtonModel options doing the following:
<div role="application">
<button>BUTTON</button>
</div>
If in user interviews we determine that this is too confusing for users, we will be in an OK position to @zepumph recommended that these decisions should be documented in style guide document files (like PushButton.md) for review from relevant people in the future. |
@samreid also provided these notes from discussion:
|
I agree that I also agree with (a) and (b) in the above comment. We need to tread very carefully with |
This means that we are proceeding with our current input system for catching |
The work described in #939 (comment) has been moved to #1117. Closing this issue. |
Reopening based on the TODO in the code: * TODO: This may change after https://github.com/phetsims/scenery/issues/939 is done, at which point
* `click` should likely be replaced by `keydown` and `keyup` listeners. |
Thanks, I updated the link to point to the new issue referenced in #939 (comment) |
From #934, in the browser they are different, @pixelzoom and @zepumph discussed at one point whether or not that adds value to phetsims, it would be good to discuss that further, and then implement from there. This also may relate to how we are handling sun buttons, and that should be looked at in this issue to.
Related potentially to phetsims/sun#424, there is likely little use for the default behavior of Enter to be fire multiple events.
Even though it is browser default, we know we want to support users at PhET that are younger, and may not have as much keyboard experience, it could easily be overwhelming to have a button fire many times without a good, pedagogical reason to. Expanding on that, then why would we make that the default behavior for Enter?
I think from discussing with @pixelzoom that we are mostly in agreement (correct me if I'm wrong) that the default behavior for both should (a) be the same, and (b) be a single click for buttons. See #931 for adding support for options that would deal with "fire on hold" features.
The text was updated successfully, but these errors were encountered: