-
Notifications
You must be signed in to change notification settings - Fork 91
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
fix(modal): prevent focus change when current focus is within modal #1549
Conversation
✅ Deploy Preview for stacks ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
…ivate property of the class #1216 (comment)
@giamir thank you for debugging the test failures for me and taking a moment to perform some clean up. I'm going to merge this in but I'd like to make sure I understand what resolved the failures. The causes of failures (as I understand)
Questions
|
Yes, syntactic sugar.
If we remove the animations the modalTarget I thought that setting the animation back for the unit tests might be a good move given that it puts our test environment even closer to how a regular user would experience it. |
https://stackoverflow.atlassian.net/browse/STACKS-412
This PR attempts to fix the issue of the modal controller attempting to set focus when focus is already set on an element within the modal by checking to see if the currently focused element is contained within the controller and only setting focus if it's not.
Current state of tests
I decided to timebox this fix and I couldn't figure out why these tests are failing only in Chrome and Firefox but not Webkit (with one exception). It looks like the modal is not getting the
aria-hidden
value changed fromtrue
tofalse
when show is triggered. This explains why the Chrome/Firefox tests are failing, but it doesn't explain why Webkit is (mostly) passing 😕@giamir I was hoping you could take a look to see if there's anything obvious to explain why 1) the
aria-hidden
value is not set as expected and 2) why tests would pass in Webkit. If you don't see anything obvious, please don't stress over it too much. I figure I'll return to this soon with fresh eyes, but I figured I'd ask for your help since I might just be too close to this.Update Thu Nov 2, 2023
When running the tests now, all tests fail in Chromium and Firefox only with this error:
Error: Error invoking action "click->s-modal#toggle" (:0)
Two of the five tests also fail in Webkit. Both of these tests check focus on specific elements but it seems that the focus is always left on the button that triggers showing the modal.