1
0
mirror of https://github.com/twbs/bootstrap.git synced 2025-09-02 18:02:37 +02:00

Add shift-tab keyboard support for dialogs (modal & Offcanvas components) (#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>
This commit is contained in:
Ryan Berliner
2021-07-27 01:01:04 -04:00
committed by GitHub
parent 8536474583
commit 7646f6bd33
9 changed files with 499 additions and 71 deletions

View File

@@ -11,6 +11,8 @@
* ------------------------------------------------------------------------
*/
import { isDisabled, isVisible } from '../util/index'
const NODE_TEXT = 3
const SelectorEngine = {
@@ -69,6 +71,21 @@ const SelectorEngine = {
}
return []
},
focusableChildren(element) {
const focusables = [
'a',
'button',
'input',
'textarea',
'select',
'details',
'[tabindex]',
'[contenteditable="true"]'
].map(selector => `${selector}:not([tabindex^="-"])`).join(', ')
return this.find(focusables, element).filter(el => !isDisabled(el) && isVisible(el))
}
}