railsdevs.com icon indicating copy to clipboard operation
railsdevs.com copied to clipboard

Trap focus in mobile filter modal while it is open

Open atiqueakhtar opened this issue 3 years ago • 6 comments

This PR resolves the issue described in #541 and satisfies all the given expected behaviour:

  • Focus should be trapped inside the modal while the modal is open (should not move back to the main page)
  • When the modal is closed, the focus should go back to the "Filters" button
  • When the "Filters" button is focused, screen readers should not announce "collapsed"

Pull request checklist

  • [ ] My code contains tests covering the code I modified (Not Required)
  • [x] I linted and tested the project with bin/check
  • [ ] I added significant changes and product updates to the changelog (Not Required)

atiqueakhtar avatar Sep 18 '22 20:09 atiqueakhtar

Hi @joemasilotti , Can you please review this PR which resolves #541 . Thanks.

atiqueakhtar avatar Sep 18 '22 21:09 atiqueakhtar

Thanks for taking a pass, @atiqueakhtar! I'm not very familiar with a11y in this context, but this feels like a lot of custom JavaScript to achieve what we want. Is there any possibility that we could do something in HTML? I was wondering if manually setting tabindex could help.

@metamoni, do you have any ideas or feedback on this?

joemasilotti avatar Sep 18 '22 22:09 joemasilotti

Thanks for taking a pass, @atiqueakhtar! I'm not very familiar with a11y in this context, but this feels like a lot of custom JavaScript to achieve what we want. Is there any possibility that we could do something in HTML? I was wondering if manually setting tabindex could help.

Sure @joemasilotti , I'll see if I can accomplish this directly through HTML rather than using custom javascript.

atiqueakhtar avatar Sep 19 '22 08:09 atiqueakhtar

Awesome, thanks for taking another pass!

joemasilotti avatar Sep 19 '22 14:09 joemasilotti

Sorry for the delay in replying to this. Just had a look and this looks great! Great job, @atiqueakhtar 👍

metamoni avatar Oct 09 '22 12:10 metamoni

Hey @atiqueakhtar, do you still have appetite to take another pass with HTML? If not, no worries! Let me know and I can take over.

joemasilotti avatar Oct 11 '22 18:10 joemasilotti

@atiqueakhtar, I'm going to close this for now as it has grown quite stale. If you'd like to pick it up again let me know!

joemasilotti avatar Nov 18 '22 21:11 joemasilotti