From 7c3f79ac1a30c30d35b5a24b697f69f80cb88a88 Mon Sep 17 00:00:00 2001 From: "Timothy Z." Date: Wed, 29 Apr 2026 16:37:51 +0300 Subject: [PATCH] refactor: correctly getActiveScope when on modal --- .../GamepadNavigation/useContentGamepadNavigation.tsx | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/services/GamepadNavigation/useContentGamepadNavigation.tsx b/src/services/GamepadNavigation/useContentGamepadNavigation.tsx index f5024f255..a7d24f4d9 100644 --- a/src/services/GamepadNavigation/useContentGamepadNavigation.tsx +++ b/src/services/GamepadNavigation/useContentGamepadNavigation.tsx @@ -3,11 +3,13 @@ import { useEffect, useRef } from 'react'; import { useGamepad } from '../GamepadContext'; -const FOCUSABLE = '[tabindex]'; +const FOCUSABLE = '[tabindex]:not([data-focus-guard])'; const getActiveScope = (fallback: HTMLDivElement | null): HTMLElement | null => { - const modal = document.querySelector('.modals-container'); - if (modal && modal.children.length > 0) return modal; + const modals = document.querySelectorAll('.modals-container'); + for (const modal of modals) { + if (modal.children.length > 0) return modal; + } const dropdown = fallback?.querySelector('[class*="dropdown"][class*="open"]'); if (dropdown) return dropdown;