feat: massive front-end overhaul and initial github release
This commit is contained in:
parent
a2b40e38bf
commit
d5a0e70580
303 changed files with 19840 additions and 676 deletions
30
src/mainview/components/AutoFocus.tsx
Normal file
30
src/mainview/components/AutoFocus.tsx
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
import { doesFocusableExist, getCurrentFocusKey } from "@noriginmedia/norigin-spatial-navigation";
|
||||
import { useEffect } from "react";
|
||||
|
||||
export function AutoFocus (data: { focus: () => void; force?: boolean; delay?: number; })
|
||||
{
|
||||
useEffect(() =>
|
||||
{
|
||||
let delayTimeout: number | undefined;
|
||||
|
||||
if (data.force || !getCurrentFocusKey() || !doesFocusableExist(getCurrentFocusKey()))
|
||||
{
|
||||
if (data.delay)
|
||||
{
|
||||
delayTimeout = window.setTimeout(() => data.focus(), data.delay);
|
||||
} else
|
||||
{
|
||||
data.focus();
|
||||
}
|
||||
|
||||
}
|
||||
return () =>
|
||||
{
|
||||
if (delayTimeout)
|
||||
{
|
||||
window.clearTimeout(delayTimeout);
|
||||
}
|
||||
};
|
||||
}, []);
|
||||
return <></>;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue