-
-
Notifications
You must be signed in to change notification settings - Fork 495
Add keyboard support #191
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
Add keyboard support #191
Conversation
For now, it handles both simple and range sliders. More keys needs to be supported. When a pointer is focused and a user start to update it with the mouse, then keyboard control doesn't work anymore. |
b5d9540
to
dddc2b0
Compare
I just added more keys such as page-up/down, home and end. Also, now, when a handle is clicked then it is automatically focused so we can update it after a slide using the keyboard. |
427ace2
to
a49fc4d
Compare
Focused handle is wrong for range slider when switching min/max with mouse. |
Its working great in the fiddle - let me review the commits and see if I have any suggestions. Awesome work |
Thanks! There is at least one bug remaining for range slider (my last comment). Also, it lacks comments and code cleaning. |
Got it. I setup the test suite - mocha etc. on your branch [keyboard-support] |
Great! I wanted to add tests for a long time but never got the time/motivation... |
I setup up coverage, as requested :) [keyboard-support] |
I am trying to figure out the testing strategy, events are difficult to handle in the unit tests, and aria does not seem to be updating in the tests, we may not be able to rely as heavily on unit tests.
Let me know if you have any suggestions on the tests, and if you have anything you would like to test specifically - plus checkout the coverage report. https://github.com/georgebatalinski/angularjs-slider/blob/keyboard-support/tests/spec/rz-slider-service-test.js |
|
On this example, I first switch min/max using keyboard: OK then with mouse: not OK. [Edit]: This bug is fixed by last commit.
Regarding the tracking state, everything is handled internally using the |
Also, it would be better if you could avoid using JQuery specific function because JQuery is not required for this library. Here's a nice example about using mocked Event without JQuery: http://stackoverflow.com/a/28924708/1713469 |
018a066
to
692441b
Compare
Got it. I removed the Jquery and tested using your technique.
this.maxH[0].focus(); We should make this on function that does the focus() focusElement(element) {
element.focus()
} this.maxH[0] 0 is not descriptive - why is it 0 - is there a significance - what else is in that array? this.tracking I have no idea what tracking is. Should it be model? since it looks like its always - 'rzSliderModel' if (this.options.keyboardSupport) Since we are supporting focus - both keyboard and mouse - wondering if we need that flag. Not sure if it is worth it to disable it, since we have accessibility folks should just have it. Here for the future - if we ever have more attributes var attributes = ['aria-valuenow'.....]
forEach(addAttribute) Everything else is awesome Let me know if you want me to look at anything else |
Thanks for this very complete feedback. ;) About the tabindex="0" on the role="slider", I do it for each handle and I don't agree about the fact that we should first focus the slider and then the pointer. Only editable elements should be focusable so there is no point focusing the whole slider. Quoted from the Mozilla reference: "The slider role is assigned to the "thumb," the control that is adjusted to change the value." Here "thumb" is our pointers. I agree that we could extract the focus logic to its own function. About the [0] syntax, it's because For the For the Lastly, about the aria-attributes, I don't understand what you want to do because each attribute gets a different value... |
692441b
to
630e326
Compare
You are fast :) The following are really small improvements.
I will create a pull request, for the test suite. |
Damn the list of commits is quite weird now. A PR on a PR was maybe not a good idea! ^^ But I don't know how to do it differently (several people working on the same PR). I'll try to fix the commits list with a big rebase. |
Rebase down! I'll modify my code with your last remarks and we should be good to go. I don't want to use ngAria because I prefer to avoid to use any dependencies... |
89637eb
to
8197e82
Compare
cool - awesome work :) |
OK do you think we are good to merge? |
Yes |
As discussed in #157.
Demo: http://jsfiddle.net/24gryyu5/
Should this be added by default or only if a keyboard option is set?
ARIA reference for sliders: https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/ARIA_Techniques/Using_the_slider_role .