From 4be326b86fedbc3e3d2afbba066b78b9b07f7183 Mon Sep 17 00:00:00 2001 From: Priyanshu Maurya Date: Sun, 5 Nov 2023 09:06:33 +0000 Subject: [PATCH] fix : Bug title not change on first click --- components/NavigationLinks.tsx | 52 ++++++++++++++-------------------- 1 file changed, 22 insertions(+), 30 deletions(-) diff --git a/components/NavigationLinks.tsx b/components/NavigationLinks.tsx index ba48d41..b4d1067 100644 --- a/components/NavigationLinks.tsx +++ b/components/NavigationLinks.tsx @@ -7,7 +7,7 @@ import useMediaQuery from "@mui/material/useMediaQuery"; export default function NavigationLinks() { const [activeSection, setActiveSection] = useState(""); - const handleSectionClick = (section) => { + const handleSectionClick = (section: string) => { setActiveSection(section); }; @@ -23,16 +23,11 @@ export default function NavigationLinks() { }, }; - const handleToolsClick = () => { - document.title = "AI Fusion - Tools"; - }; - const handlePromptsClick = () => { - document.title = "AI Fusion - Prompts"; - }; + const handleClick = (event: React.MouseEvent, title: string) => { + event.preventDefault(); - const handleDatasetsClick = () => { - document.title = "AI Fusion - Datasets"; + document.title = `AI Fusion | ${title}`; }; return ( @@ -43,43 +38,40 @@ export default function NavigationLinks() { >
{ + onClick={(event) => { handleSectionClick("tools"); - handleToolsClick(); + handleClick(event, "Tools"); }} > Tools { + onClick={(event) => { handleSectionClick("prompts"); - handlePromptsClick(); + handleClick(event, "Prompts"); }} > Prompts { + onClick={(event) => { handleSectionClick("datasets"); - handleDatasetsClick(); + handleClick(event, "Datasets"); }} > Datasets