mirror of
https://github.com/Stremio/stremio-web.git
synced 2026-05-18 02:41:54 +00:00
refactor: make sure the gamepad modal focus is respected
This commit is contained in:
parent
7c3f79ac1a
commit
73a02564b3
2 changed files with 3 additions and 1 deletions
|
|
@ -68,7 +68,7 @@ const GamepadModal = ({ onClose }: Props) => {
|
||||||
}, [gamepad]);
|
}, [gamepad]);
|
||||||
|
|
||||||
return createPortal((
|
return createPortal((
|
||||||
<div className={styles['gamepad-modal']}>
|
<div className={styles['gamepad-modal']} data-gamepad-modal>
|
||||||
<div className={styles['backdrop']} onClick={onClose} />
|
<div className={styles['backdrop']} onClick={onClose} />
|
||||||
|
|
||||||
<div className={styles['container']}>
|
<div className={styles['container']}>
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,8 @@ import { useGamepad } from '../GamepadContext';
|
||||||
const FOCUSABLE = '[tabindex]:not([data-focus-guard])';
|
const FOCUSABLE = '[tabindex]:not([data-focus-guard])';
|
||||||
|
|
||||||
const getActiveScope = (fallback: HTMLDivElement | null): HTMLElement | null => {
|
const getActiveScope = (fallback: HTMLDivElement | null): HTMLElement | null => {
|
||||||
|
if (document.querySelector('[data-gamepad-modal]')) return null;
|
||||||
|
|
||||||
const modals = document.querySelectorAll<HTMLElement>('.modals-container');
|
const modals = document.querySelectorAll<HTMLElement>('.modals-container');
|
||||||
for (const modal of modals) {
|
for (const modal of modals) {
|
||||||
if (modal.children.length > 0) return modal;
|
if (modal.children.length > 0) return modal;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue