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

Activate/toggle buttons with space on keyup #858

Merged
merged 2 commits into from
Sep 13, 2018
Merged

Activate/toggle buttons with space on keyup #858

merged 2 commits into from
Sep 13, 2018

Conversation

kleinfreund
Copy link
Contributor

@kleinfreund kleinfreund commented Aug 27, 2018

Implements #610.

Both action and toggle buttons are now activated with space on the keyup event and no longer on the keydown event. The behavior for pressing enter has not changed.

As brought up in #610, I would like to remove the safety check on lines 66 to 69 (in the new file). What are your thoughts on that?

Also, do you want me to expand the description in the design pattern to reflect this behavior?

@mcking65 mcking65 requested review from sh0ji and jongund and removed request for jongund August 29, 2018 01:49
Copy link
Contributor

@sh0ji sh0ji left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Enter should only trigger on keydown, not keyup. Everything else looks good! I have no objection to removing the role check.

*/
function actionButtonKeyupHandler (event) {
// If either enter or space is pressed, activate the button
if (event.keyCode === 13 || event.keyCode === 32) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Enter check should be removed here. It's causing activateActionButton to trigger twice on Enter keypresses, effectively making the toggle button pointless.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, what a blunder. Of course.

* @param {KeyboardEvent} event
*/
function toggleButtonKeyupHandler (event) {
if (event.keyCode === 13 || event.keyCode === 32) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same thing as line 49 here.

examples/button/js/button.js Show resolved Hide resolved
@mcking65 mcking65 merged commit c301653 into w3c:master Sep 13, 2018
michael-n-cooper pushed a commit that referenced this pull request Sep 13, 2018
Button examples: Activate buttons on keyup for space key (pull #858)

To resolve issue #610, activate  buttons on keyup when space is pressed.
Enter key behavior is not changed.
Makes behavior consistent with HTML button elements.
@kleinfreund kleinfreund deleted the button-space-keyup branch September 13, 2018 18:14
spectranaut pushed a commit to bocoup/aria-practices that referenced this pull request Sep 13, 2018
To resolve issue w3c#610, activate  buttons on keyup when space is pressed.
Enter key behavior is not changed.
Makes behavior consistent with HTML button elements.
spectranaut pushed a commit to bocoup/aria-practices that referenced this pull request Sep 14, 2018
To resolve issue w3c#610, activate  buttons on keyup when space is pressed.
Enter key behavior is not changed.
Makes behavior consistent with HTML button elements.
@caasi
Copy link

caasi commented Oct 21, 2019

My friend is working on her own ARIA practices. We are wondering if there is any reference about this keyup behavior other than the "Change History" section of WAI-ARIA Authoring Practices 1.1. Can anyone point a direction?

@ZoeBijl
Copy link
Contributor

ZoeBijl commented Oct 21, 2019

My friend is working on her own ARIA practices.

Is it open source?

We are wondering if there is any reference about this keyup behavior other than the "Change History" section of WAI-ARIA Authoring Practices 1.1. Can anyone point a direction?

This was done to better match what the HTML button element does on native platforms.

@caasi
Copy link

caasi commented Oct 22, 2019

Is it open source?

Currently it's just a code sandbox.

This was done to better match what the HTML button element does on native platforms.

You are right. Another friend @othree found an answer about this behavior here: https://stackoverflow.com/questions/16090578/why-do-enter-and-space-keys-behave-differently-for-buttons

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants