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

Add shift-tab keyboard support for dialogs (modal & Offcanvas components) #33865

Merged
merged 7 commits into from
Jul 27, 2021

Conversation

RyanBerliner
Copy link
Contributor

@RyanBerliner RyanBerliner commented May 7, 2021

Fixes #28481

  • Share focus trapping behavior between modal and Offcanvas components
  • Allow shift-tab keyboard navigation to wrap around backwards (go to the last focusable element)

There are a couple issues (primarily #33804) that aim to fix inconsistent screen reader navigation or announcements. The work I've done here only concerns tab navigation.

TODO:

Preview Modal
Preview Offcanvas

Sorry, something went wrong.

@RyanBerliner RyanBerliner force-pushed the dialog-focus branch 2 times, most recently from b6b8f06 to 7e7a0a5 Compare May 21, 2021 00:50
@RyanBerliner RyanBerliner marked this pull request as ready for review May 21, 2021 00:56
@RyanBerliner RyanBerliner requested a review from a team as a code owner May 21, 2021 00:56
@GeoSot
Copy link
Member

GeoSot commented Jun 6, 2021

@RyanBerliner can you rebase your MR please?

@RyanBerliner
Copy link
Contributor Author

@GeoSot I've rebased. It looks like #33327 introduced a dependency of selector-engine.js for util/index.js. Combine this with my previous work on this PR and it's throwing circular dependency warning between the util index and selector engine files. I'm open to any number of resolutions, though IMO it seems that the getElement() in the util index file might be best suited living in the selector engine file? Let me know what you'd prefer to see done.

@GeoSot
Copy link
Member

GeoSot commented Jun 8, 2021

though IMO it seems that the getElement() in the util index file might be best suited living in the selector engine file?

Yes, seems right as it has a foreign dependency. Can you handle it ? (maybe isElement need to follow getElement)
I suppose is better on a separate MR

/cc @rohit2sharma95 , @alpadev

@RyanBerliner
Copy link
Contributor Author

I hadn't realized how dependent other utility functions were on getElement() and isElement()... so moving either of those to selector engine would likely turn into some larger, and questionable refactoring. To avoid this I've decided instead to move focusableChildren() to the utility file. I think this can be justified since focusableChildren() does have some more opinionated logic in it that isn't as straight forward as the other selector engine functions.

@GeoSot GeoSot self-assigned this Jun 10, 2021
@GeoSot
Copy link
Member

GeoSot commented Jul 6, 2021

Seems good to my eyes.

CC: @twbs/js-review

@GeoSot GeoSot requested a review from a team July 6, 2021 22:49
GeoSot
GeoSot previously approved these changes Jul 6, 2021
@GeoSot GeoSot requested review from a team and GeoSot July 8, 2021 14:04
@GeoSot GeoSot dismissed their stale review July 14, 2021 09:30

changes cuased of #34441

@GeoSot
Copy link
Member

GeoSot commented Jul 20, 2021

@RyanBerliner , can we update this MR (and resolve the suggestion)?

@XhmikosR
Copy link
Member

@patrickhlauke: LGTY?

@XhmikosR XhmikosR requested a review from patrickhlauke July 21, 2021 16:05
@XhmikosR
Copy link
Member

FYI This doesn't pass on BrowserStack + there are some warnings: https://github.com/twbs/bootstrap/runs/3125887723

We should get those sorted before landing this :)

@RyanBerliner
Copy link
Contributor Author

@XhmikosR the warnings seem simple enough, I can handle them. The failed tests on the other hand seem to be related to differences in how the <area> tag is selected. This came up in #33960, and we decided to just drop special handling of this element... I'm wondering if you all think it may be most practical to drop it from the selector here as well since it's used so little. Otherwise, happy to troubleshoot... just want to make sure everyone believes it's worth it since it's a funky element. I'm leaning towards dropping it.

@GeoSot
Copy link
Member

GeoSot commented Jul 26, 2021

I will support the 'drop' case, for one more time. However try to leave a comment about it, for future reference

Copy link
Member

@patrickhlauke patrickhlauke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Testing the behaviour, this now seems to behave correctly. Not looked at the code side, but from a functional point of view, this looks good to me

@RyanBerliner
Copy link
Contributor Author

@XhmikosR I'm not sure I have the permission to re-run browserstack tests, however I believe everything should be resolved. If there are still warnings or errors that you'd like me to revisit lmk.

RyanBerliner and others added 6 commits July 27, 2021 02:21

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
Co-authored-by: GeoSot <geo.sotis@gmail.com>

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
@XhmikosR
Copy link
Member

All good @RyanBerliner thanks!

Also, thanks to @GeoSot everything seems to be good to go.

@XhmikosR XhmikosR merged commit 7646f6b into twbs:main Jul 27, 2021
marvin-hinkley-vortx pushed a commit to Vortx-Inc/bootstrap that referenced this pull request Aug 18, 2021
…nts) (twbs#33865)

* consolidate dialog focus trap logic

* add shift-tab support to focustrap

* remove redundant null check of trap element

Co-authored-by: GeoSot <geo.sotis@gmail.com>

* remove area support forom focusableChildren

* fix no expectations warning in focustrap tests

Co-authored-by: GeoSot <geo.sotis@gmail.com>
Co-authored-by: XhmikosR <xhmikosr@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

v5: Modal focus changes
4 participants