From c4e056711b231fdeb7b794c3ed7a5d03711d3bc2 Mon Sep 17 00:00:00 2001 From: tigattack <10629864+tigattack@users.noreply.github.com> Date: Fri, 26 Sep 2025 20:00:35 +0100 Subject: [PATCH] fix(frontend): use React Router navigation to open add host modal Fixes page reload on add host button click. --- frontend/src/components/Layout.jsx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/frontend/src/components/Layout.jsx b/frontend/src/components/Layout.jsx index c5952e6..90f212c 100644 --- a/frontend/src/components/Layout.jsx +++ b/frontend/src/components/Layout.jsx @@ -28,7 +28,7 @@ import { X, } from "lucide-react"; import { useCallback, useEffect, useRef, useState } from "react"; -import { Link, useLocation } from "react-router-dom"; +import { Link, useLocation, useNavigate } from "react-router-dom"; import { useAuth } from "../contexts/AuthContext"; import { useUpdateNotification } from "../contexts/UpdateNotificationContext"; import { dashboardAPI, versionAPI } from "../utils/api"; @@ -44,6 +44,7 @@ const Layout = ({ children }) => { const [_userMenuOpen, setUserMenuOpen] = useState(false); const [githubStars, setGithubStars] = useState(null); const location = useLocation(); + const navigate = useNavigate(); const { user, logout, @@ -236,7 +237,7 @@ const Layout = ({ children }) => { const handleAddHost = () => { // Navigate to hosts page with add modal parameter - window.location.href = "/hosts?action=add"; + navigate("/hosts?action=add"); }; // Fetch GitHub stars count