Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/react-aria/src/interactions/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ export let ignoreFocusEvent = false;
*/
export function preventFocus(target: FocusableElement | null): (() => void) | undefined {
// The browser will focus the nearest focusable ancestor of our target.
while (target && !isFocusable(target)) {
while (target && !isFocusable(target, {skipVisibilityCheck: true})) {
target = target.parentElement;
}

Expand Down
4 changes: 2 additions & 2 deletions packages/react-aria/src/utils/isFocusable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ const FOCUSABLE_ELEMENT_SELECTOR = focusableElements.join(':not([hidden]),') + '
focusableElements.push('[tabindex]:not([tabindex="-1"]):not([disabled])');
const TABBABLE_ELEMENT_SELECTOR = focusableElements.join(':not([hidden]):not([tabindex="-1"]),');

export function isFocusable(element: Element): boolean {
return element.matches(FOCUSABLE_ELEMENT_SELECTOR) && isElementVisible(element) && !isInert(element);
export function isFocusable(element: Element, options?: {skipVisibilityCheck?: boolean}): boolean {
return element.matches(FOCUSABLE_ELEMENT_SELECTOR) && !isInert(element) && (options?.skipVisibilityCheck || isElementVisible(element));
}

export function isTabbable(element: Element): boolean {
Expand Down
Loading