From dc9bd8693e43a40c93a691e6ab9f051c63fbdcc3 Mon Sep 17 00:00:00 2001 From: lifeparticle Date: Sat, 28 Oct 2023 16:33:28 +1100 Subject: [PATCH] fix --- ui/src/hooks/useCombinedKeyPress.ts | 4 ++-- ui/src/pages/Markdown/TableOfContent/index.tsx | 16 ++++++++++------ 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/ui/src/hooks/useCombinedKeyPress.ts b/ui/src/hooks/useCombinedKeyPress.ts index 3552fcc6..7425172a 100644 --- a/ui/src/hooks/useCombinedKeyPress.ts +++ b/ui/src/hooks/useCombinedKeyPress.ts @@ -48,7 +48,7 @@ function useCombinedKeyPress( }; }, [handleKeyDown, handleKeyUp]); - function compareArrays(pressedArray: string[], mainArray: string[]) { + const compareArrays = (pressedArray: string[], mainArray: string[]) => { if (pressedArray?.length !== mainArray?.length) return false; for (const iterator of mainArray) { @@ -59,7 +59,7 @@ function useCombinedKeyPress( } return true; - } + }; } export default useCombinedKeyPress; diff --git a/ui/src/pages/Markdown/TableOfContent/index.tsx b/ui/src/pages/Markdown/TableOfContent/index.tsx index 88223267..3c1caced 100644 --- a/ui/src/pages/Markdown/TableOfContent/index.tsx +++ b/ui/src/pages/Markdown/TableOfContent/index.tsx @@ -79,10 +79,11 @@ const TableOfContent: React.FC = () => { .join("\n"); }; - const fetchData = (url: string) => { - setUrl(url); + const fetchData = (value: string) => { + setUrl(value); + if (!value) return; - fetch(url) + fetch(value) .then((res) => res.text()) .then( (result) => { @@ -104,9 +105,12 @@ const TableOfContent: React.FC = () => { label="Input URL" placeholder="URL" value={url} - onChange={(event) => - fetchData(event.currentTarget.value) - } + onChange={(event) => { + console.log("ddd"); + setMarkdown(""); + setTableOfContents(""); + fetchData(event.target.value); + }} type="text" />