diff options
| author | Ryan Berliner <[email protected]> | 2021-07-27 01:01:04 -0400 |
|---|---|---|
| committer | GitHub <[email protected]> | 2021-07-27 08:01:04 +0300 |
| commit | 7646f6bd33a03132e446fb060880bbf051a1639f (patch) | |
| tree | a2addfd5e2f99b23322cd053ca0ec53c48cf6fc6 /js/src/dom | |
| parent | 85364745831ba5513ee7e940fe571cb4268810b8 (diff) | |
| download | bootstrap-7646f6bd33a03132e446fb060880bbf051a1639f.tar.xz bootstrap-7646f6bd33a03132e446fb060880bbf051a1639f.zip | |
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 <[email protected]>
* remove area support forom focusableChildren
* fix no expectations warning in focustrap tests
Co-authored-by: GeoSot <[email protected]>
Co-authored-by: XhmikosR <[email protected]>
Diffstat (limited to 'js/src/dom')
| -rw-r--r-- | js/src/dom/selector-engine.js | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/js/src/dom/selector-engine.js b/js/src/dom/selector-engine.js index 381e45fe8..88f924076 100644 --- a/js/src/dom/selector-engine.js +++ b/js/src/dom/selector-engine.js @@ -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)) } } |
