From 6068fab7e46ad05c812823f61d71f9e09645c2f6 Mon Sep 17 00:00:00 2001 From: AlexSciFier <66871322+AlexSciFier@users.noreply.github.com> Date: Wed, 4 Dec 2024 17:00:01 +0300 Subject: [PATCH 1/2] Changed autocomplete behavior --- frontend/src/pages/addBookmark/index.jsx | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/frontend/src/pages/addBookmark/index.jsx b/frontend/src/pages/addBookmark/index.jsx index ad24ecc..cd29cf5 100644 --- a/frontend/src/pages/addBookmark/index.jsx +++ b/frontend/src/pages/addBookmark/index.jsx @@ -50,7 +50,6 @@ export default function AddPage() { const [url, setUrl] = useState(""); const [complete, setComplete] = useState(false); const [error, setError] = useState(); - const [urlError, setUrlError] = useState(); const urlRef = useRef(null); @@ -91,8 +90,8 @@ export default function AddPage() { }; async function fetchUrl() { - setUrlError(undefined); if (url === "") return; + if (!url.startsWith("http")) return; setIsLoading(true); let res; @@ -108,10 +107,9 @@ export default function AddPage() { setFormData({ ...formData, ...(await res.json()), tags: formData.tags }); setIsLoading(false); } else { - console.error("error", res.statusText, res.status); let body = await res.json(); let reason = body.message; - notify("Error", reason, "error"); + console.error(reason); setIsLoading(false); } } @@ -148,14 +146,12 @@ export default function AddPage() { try { new URL(url); } catch (error) { - setUrl("https://" + url); + if (url !== "" && !url.startsWith("http")) setUrl("https://" + url); } }; function isButtonDisabled() { - return error || urlError || sending || isLoading || url === "" - ? true - : false; + return error || sending || isLoading || url === "" ? true : false; } if (complete) { @@ -226,9 +222,7 @@ export default function AddPage() { ))}