diff --git a/src/components/App.tsx b/src/components/App.tsx index dfa4396..aac363a 100644 --- a/src/components/App.tsx +++ b/src/components/App.tsx @@ -17,9 +17,7 @@ const App: React.FC = () => {
-
-
diff --git a/src/components/Browser.tsx b/src/components/Browser.tsx index b6d19d9..acc5e94 100644 --- a/src/components/Browser.tsx +++ b/src/components/Browser.tsx @@ -135,12 +135,16 @@ async function bootup() { } } +const NavInput = forwardRef((props: React.HTMLProps, ref) => { + return ; +}); + export function Navigator() { const { url: contextUrl, setUrl } = useBrowserState(); - const [inputValue, setInputValue] = useState(contextUrl); // Local state for the input value const { ready } = useLumeStatus(); + const inputEl = useRef(); - const browse = () => { + const browse = (inputValue: string) => { let input = inputValue.trim(); // If the input doesn't contain a protocol, assume it's http @@ -160,27 +164,33 @@ export function Navigator() { }; useEffect(() => { - setInputValue(contextUrl); // Update local state when context's url changes + if(inputEl.current) { + inputEl.current.value = contextUrl; + } }, [contextUrl]); - const NavInput = forwardRef((props: any, ref) => { - return ; - }); - console.log("Navigator mounted"); return ( - <> +
{ + e.preventDefault(); + const inputElement = e.target as HTMLFormElement; + const inputValue = inputElement?.elements.namedItem('url')?.value; + if (inputValue) { + browse(inputValue) + } + }} className="relative h-full w-full rounded-full bg-neutral-800 border border-neutral-700 flex items-center [>input:focus]:ring-2 [>input:focus]:ring-white"> setInputValue(e.target.value)} + ref={inputEl} disabled={!ready} + className="rounded-l-full border-none" + name="url" /> - - + ); }