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

Is there a way to control the slider position using the keyboard? #31

Closed
lucianourgal opened this issue Mar 29, 2021 · 6 comments
Closed
Labels
enhancement New feature or request question Further information is requested

Comments

@lucianourgal
Copy link

This would be interesting because of accessibility issues.

@nerdyman
Copy link
Owner

nerdyman commented Mar 30, 2021

Hi @lucianourgal, thanks for opening this issue!

The library doesn't currently provide keyboard bindings but I'm definitely onboard with implementing some functionality or accepting a PR. I looked into it briefly before but was unsure on how to make the component properly accessible (with the correct aria tags etc.).

With the current version it's possible to implement your own keyboard functionality by adding a tabIndex to the slider component to make it foscuable and then updating the position property on the slider when keyboard left, right, up, or down is pressed.

Here's a super basic demo listening to the ArrowLeft and ArrowRight keydown events to move the slider position left or right when the slider has focus.

@nerdyman nerdyman added enhancement New feature or request question Further information is requested labels Mar 30, 2021
@lucianourgal
Copy link
Author

Thank you @nerdyman, it worked!

@nerdyman
Copy link
Owner

Awesome! Thanks for opening the issue, I'll see if there's a clean way to add this to library in future.

@moloko
Copy link

moloko commented May 13, 2021

Apologies for commenting on a closed issue, but just wanted to suggest that alternative way to do this would be to include an HTML 'range' <input> element that's visually hidden but could still be accessed by assistive tech. As this is a standard HTML element it shouldn't require any extra work to make it accessible.

I'm going to be using this component on a project I'm working on which will need to have accessibility support - so I plan to try something along these lines.

Really nice component btw, thanks for making this available.

@nerdyman
Copy link
Owner

That's a good shout @moloko! Let me know how it goes, I'm totes up for improving accessibility.

@nerdyman
Copy link
Owner

This has been released in v3!

npm install react-compare-slider@latest
yarn add react-compare-slider@latest
pnpm install react-compare-slider@latest

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants