mirror of
https://github.com/Stremio/stremio-web.git
synced 2026-03-30 19:08:48 +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]);
|
||||
React.useEffect(() => {
|
||||
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]);
|
||||
return (
|
||||
|
|
|
|||
Loading…
Reference in a new issue