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

Support spacebar and enter key press on AnchorButtons #430

Closed
jkillian opened this issue Jan 9, 2017 · 7 comments
Closed

Support spacebar and enter key press on AnchorButtons #430

jkillian opened this issue Jan 9, 2017 · 7 comments

Comments

@jkillian
Copy link
Contributor

jkillian commented Jan 9, 2017

Ideally, it would be great if AnchorButton behaved like Button/<button> when it has focus and the space bar or enter key is pressed. (At the least, they should trigger the onClick handler, even if the exact active state behavior isn't identical.) This is needed for users who do everything via the keyboard and also for accessibility reasons.

@jkillian
Copy link
Contributor Author

jkillian commented Jan 9, 2017

Note that currently, pressing the spacebar on an AnchorButton does nothing. For a regular Button, it'll display the active state while held down and trigger the button when released.

Also currently, pressing the enter key on an AnchorButton does nothing (unless an href is specified then it'll navigate to that link as a regular a tag will). For a regular Button, holding down enter triggers the button and then repeatedly triggers it while the key is held down.

@giladgray
Copy link
Contributor

Thanks for the detailed behavior explanation. Is this consistent across browsers?

Should we attempt to replicate the button behavior for AnchorButton? Or perhaps standardize both to a simple single click?

@jkillian
Copy link
Contributor Author

jkillian commented Jan 9, 2017

Is this consistent across browsers?

Almost, as far as I can tell. In FF, holding down space doesn't trigger the button's active state, but the timing of when the events are fired is the same (upon spacebar release, and while the enter key is held down)

@jkillian
Copy link
Contributor Author

jkillian commented Jan 9, 2017

Should we attempt to replicate the button behavior for AnchorButton? Or perhaps standardize both to a simple single click?

I think we likely should - nicer to have Blueprint buttons follow standard browser interaction semantics than do something different. I think it should be pretty easy to replicate actually: enter fires onClick on its onKeyDown events, spacebar fires onClick on its onKeyUp events

@llorca
Copy link
Contributor

llorca commented Jan 9, 2017

It's something that's terribly inconsistent across browser. I'm on board to make this great in Blueprint, but let's be careful and not break <a>s entirely, should only work for a.pt-button I suppose.

@jkillian

enter fires onClick on its onKeyDown events, spacebar fires onClick on its onKeyUp events

Is it standard stuff? I never knew about the difference between enter and space

@giladgray
Copy link
Contributor

it'll only work for AnchorButton JSX elements, not any old a.pt-button tag. i'm down!

@jkillian
Copy link
Contributor Author

Is it standard stuff? I never knew about the difference between enter and space

I'm unsure. It's the behavior I observed in Chrome and in FF, but I don't know if it's an official standard, or just an implementation detail that both browsers agree on

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

No branches or pull requests

5 participants