From 197ac0dd362ae153bcd513925301382211afcfe2 Mon Sep 17 00:00:00 2001 From: Andrew Date: Tue, 8 Apr 2025 15:42:38 +0100 Subject: [PATCH] [frontend]: Add scrollbar to sidebar on short screens --- frontend/src/components/Sidebar.jsx | 40 ++++++++++++++++++++++++----- 1 file changed, 33 insertions(+), 7 deletions(-) diff --git a/frontend/src/components/Sidebar.jsx b/frontend/src/components/Sidebar.jsx index 9d38ec7..6fb37da 100644 --- a/frontend/src/components/Sidebar.jsx +++ b/frontend/src/components/Sidebar.jsx @@ -182,6 +182,14 @@ const Sidebar = ({ selectedSources, setSelectedSources, clusteringEnabled, setCl const [enabledSources, setEnabledSources] = useState([]); // New state to track enabled sources const [numberInputValue, setNumberInputValue] = useState(""); // State to manage number input value const hasMounted = useRef(false); + const [isMobile, setIsMobile] = useState(false); + + useEffect(() => { + const checkMobile = () => setIsMobile(window.innerWidth <= 768); + checkMobile(); // run on mount + window.addEventListener("resize", checkMobile); + return () => window.removeEventListener("resize", checkMobile); + }, []); // Load selected sources from cookies or set all as default checked useEffect(() => { @@ -234,14 +242,32 @@ const Sidebar = ({ selectedSources, setSelectedSources, clusteringEnabled, setCl return (
- {isOpen && (