mirror of
https://github.com/Stremio/stremio-web.git
synced 2026-04-20 06:32:11 +00:00
focus content container only if it does not contain focus already
This commit is contained in:
parent
d43ca4b786
commit
70c40a22c9
1 changed files with 6 additions and 3 deletions
|
|
@ -31,16 +31,19 @@ const FocusableProvider = ({ children, onRoutesContainerDomTreeChange, onModalsC
|
|||
return () => {
|
||||
routesContainerDomTreeObserver.disconnect();
|
||||
modalsContainerDomTreeObserver.disconnect();
|
||||
}
|
||||
};
|
||||
}, [routesContainer, modalsContainer, onRoutesContainerDomTreeChange, onModalsContainerDomTreeChange]);
|
||||
React.useEffect(() => {
|
||||
if (focusable) {
|
||||
if (focusable && !contentContainerRef.current.contains(document.activeElement)) {
|
||||
contentContainerRef.current.focus();
|
||||
}
|
||||
}, [focusable]);
|
||||
return (
|
||||
<FocusableContext.Provider value={focusable}>
|
||||
{React.cloneElement(React.Children.only(children), { ref: contentContainerRef, tabIndex: -1 })}
|
||||
{React.cloneElement(React.Children.only(children), {
|
||||
ref: contentContainerRef,
|
||||
tabIndex: -1
|
||||
})}
|
||||
</FocusableContext.Provider>
|
||||
);
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in a new issue