mirror of
https://github.com/Stremio/stremio-web.git
synced 2026-04-21 03:22:11 +00:00
try to find focusable candidate before focus the container
This commit is contained in:
parent
33b6bb0290
commit
5bddb97fa9
1 changed files with 6 additions and 1 deletions
|
|
@ -35,7 +35,12 @@ const FocusableProvider = ({ children, onRoutesContainerChildrenChange, onModals
|
||||||
}, [routesContainer, modalsContainer, onRoutesContainerChildrenChange, onModalsContainerChildrenChange]);
|
}, [routesContainer, modalsContainer, onRoutesContainerChildrenChange, onModalsContainerChildrenChange]);
|
||||||
React.useEffect(() => {
|
React.useEffect(() => {
|
||||||
if (focusable && !contentContainerRef.current.contains(document.activeElement)) {
|
if (focusable && !contentContainerRef.current.contains(document.activeElement)) {
|
||||||
contentContainerRef.current.focus();
|
const focusableElement = contentContainerRef.current.querySelector('[tabindex]:not([tabindex="-1"])');
|
||||||
|
if (focusableElement instanceof HTMLElement) {
|
||||||
|
focusableElement.focus();
|
||||||
|
} else {
|
||||||
|
contentContainerRef.current.focus();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}, [focusable]);
|
}, [focusable]);
|
||||||
return (
|
return (
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue