v5: Modal focus changes
See original GitHub issueSkipping some previous v4-based PRs given our move to regular JS has already landed in master.
- #25277: Modal tabbing and shift+tabbing behavior
- #27646: Allow shift-tab focusing for modals
- #25651: Modal input autofocus attr & keyboard nav
- #21661: shift+tab without focused element within modal
- #27241: SHIFT + TAB should cycle backwards
/cc @Johann-S
Issue Analytics
- State:
- Created 5 years ago
- Comments:14 (13 by maintainers)
Top Results From Across the Web
Modal · Bootstrap v5.0
Use Bootstrap's JavaScript modal plugin to add dialogs to your site for lightboxes, user notifications, or completely custom content.
Read more >Bootstrap V5 manually call a modal myModal.show() not ...
The modal plugin toggles your hidden content on demand, via data attributes or JavaScript. It also adds .modal-open to the to override ...
Read more >Modal · Boosted v5.1
Before getting started with Boosted's modal component, be sure to read the following as our menu options have recently changed. Modals are built...
Read more ><Modal/> Component - React-Bootstrap
Modal's "trap" focus in them, ensuring the keyboard navigation cycles through the modal, and not the rest of the page. Unlike vanilla Bootstrap,...
Read more >ion-modal: Ionic Mobile App Custom Modal API Component
A Modal is a dialog that appears on top of the app's content, and must be dismissed by the app before interaction can...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Lots of mentions about
TABandSHIFT + TABbehavior in a couple issues, this seems to be the most current so hopefully its the correct spot.I also agree that
SHIFT + TABshould jump focus to the last focusable element in the modal when pressed with focus on the first focusable element. The recommended design pattern and keyboard support put out by w3c explains this as well. https://www.w3.org/TR/wai-aria-practices-1.1/examples/dialog-modal/dialog.htmlWould this still be a welcomed change? Or is there a reason behind its current implementation?
The behavior I’ve described is present in v4, and v5, as seen on the doc pages. https://getbootstrap.com/docs/4.5/components/modal/ https://v5.getbootstrap.com/docs/5.0/components/modal/
I’d be glad to put in some time to submit a pr for this - first though I’d like to make sure that the bootstrap team is on board with doing this for v5, specifically following this proof of concept as a roadmap for implementing the desired behavior. I’d imagine as a follow up pr to resolving this issue, the same behavior should be inherited into the new Offcanvas component, using a similar inheritance pattern as the relationship between tooltips and popovers.