elwayman02 / ember-scroll-modifiers

Scroll-based Modifiers for Ember.js Applications
https://ember-scroll-modifiers.jhawk.co/
MIT License
21 stars 11 forks source link

[A11y] Set focus on scroll-into-view #1091

Closed rajbirsingh83 closed 4 weeks ago

rajbirsingh83 commented 4 weeks ago

Summary

Currently, scroll-into-view modifier scrolls the element into the viewport but does not move the focus to the element. As such, it causes accessibility issue when the trigger element (like a button on the page that sets shouldScroll as true) is different from the modifier element, because the user sees the modifier element in the viewport but the focus remains on the trigger element (which might be out of viewport by now). So, the keyboard user has to navigate all the way from trigger element to modifier element.

To avoid this issue and be accessibility compliant, we can allow consumers of the modifier to enable auto setting of focus on scroll-into-view:

Testing

$ yarn test

[test:ember] 1..50
[test:ember] # tests 50
[test:ember] # pass  50
[test:ember] # skip  0
[test:ember] # todo  0
[test:ember] # fail  0
[test:ember] 
[test:ember] # ok

Screen recordings

using Mouse

https://github.com/user-attachments/assets/638065c8-6cec-4bfa-b2f3-e6f1724a594d

using Keyboard (Chrome)

https://github.com/user-attachments/assets/572dc40c-a307-47f4-b7a6-4d9da3091c58

using Keyboard (Safari)

https://github.com/user-attachments/assets/d786f0c4-df15-457c-8497-0438f56aad94

elwayman02 commented 4 weeks ago

Looks like there are a couple minor linting errors.

elwayman02 commented 4 weeks ago

The test failure isn't caused by your PR, but you can fix it by bumping this line to 18.20.4: https://github.com/elwayman02/ember-scroll-modifiers/blob/master/package.json#L101