mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-18 19:21:34 +08:00
fix(overlays): focus trapping no longer includes disabled elements (#25949)
This commit is contained in:
@ -88,10 +88,14 @@ export const createOverlay = <T extends HTMLIonOverlayElement>(
|
||||
* interactive elements that meet the following
|
||||
* criteria:
|
||||
* 1. Element does not have a negative tabindex
|
||||
* 2. Element does not have [hidden]
|
||||
* 2. Element does not have `hidden`
|
||||
* 3. Element does not have `disabled` for non-Ionic components.
|
||||
* 4. Element does not have `disabled` or `disabled="true"` for Ionic components.
|
||||
* Note: We need this distinction because `disabled="false"` is
|
||||
* valid usage for the disabled property on ion-button.
|
||||
*/
|
||||
const focusableQueryString =
|
||||
'[tabindex]:not([tabindex^="-"]):not([hidden]), input:not([type=hidden]):not([tabindex^="-"]):not([hidden]), textarea:not([tabindex^="-"]):not([hidden]), button:not([tabindex^="-"]):not([hidden]), select:not([tabindex^="-"]):not([hidden]), .ion-focusable:not([tabindex^="-"]):not([hidden])';
|
||||
'[tabindex]:not([tabindex^="-"]):not([hidden]):not([disabled]), input:not([type=hidden]):not([tabindex^="-"]):not([hidden]):not([disabled]), textarea:not([tabindex^="-"]):not([hidden]):not([disabled]), button:not([tabindex^="-"]):not([hidden]):not([disabled]), select:not([tabindex^="-"]):not([hidden]):not([disabled]), .ion-focusable:not([tabindex^="-"]):not([hidden]):not([disabled]), .ion-focusable[disabled="false"]:not([tabindex^="-"]):not([hidden])';
|
||||
|
||||
export const focusFirstDescendant = (ref: Element, overlay: HTMLIonOverlayElement) => {
|
||||
let firstInput = ref.querySelector(focusableQueryString) as HTMLElement | null;
|
||||
|
Reference in New Issue
Block a user