diff --git a/packages/vuetify/src/util/helpers.ts b/packages/vuetify/src/util/helpers.ts index 8662354797f..570a933a80a 100644 --- a/packages/vuetify/src/util/helpers.ts +++ b/packages/vuetify/src/util/helpers.ts @@ -650,11 +650,16 @@ export function callEvent (handler: EventProp | EventProp } } +function isRendered (el: HTMLElement) { + return !!el.offsetParent || el.getClientRects().length > 0 +} + export function focusableChildren (el: Element, filterByTabIndex = true) { const targets = ['button', '[href]', 'input:not([type="hidden"])', 'select', 'textarea', '[tabindex]'] - .map(s => `${s}${filterByTabIndex ? ':not([tabindex="-1"])' : ''}:not([disabled])`) + .map(s => `${s}${filterByTabIndex ? ':not([tabindex="-1"])' : ''}:not([disabled]):not(:is([inert] *))`) .join(', ') - return [...el.querySelectorAll(targets)] as HTMLElement[] + return ([...el.querySelectorAll(targets)] as HTMLElement[]) + .filter(isRendered) } export function getNextElement (elements: HTMLElement[], location?: 'next' | 'prev', condition?: (el: HTMLElement) => boolean) {