diff --git a/public/scss/style.scss b/public/scss/style.scss index ba764463f..f06f6c679 100644 --- a/public/scss/style.scss +++ b/public/scss/style.scss @@ -93,6 +93,7 @@ body { position: fixed; top: 0px; bottom: 0px; + overflow-y: auto; } } diff --git a/public/ts/sidebar.tsx b/public/ts/sidebar.tsx index a900ed756..7b911fcd8 100644 --- a/public/ts/sidebar.tsx +++ b/public/ts/sidebar.tsx @@ -1,3 +1,4 @@ +import { useEffect, useRef, useState } from "preact/hooks"; import { ComponentChildren } from "preact"; import { logout } from "./common"; import Cart from "./cart"; @@ -15,11 +16,28 @@ const NavItem = ({ url, icon, children }: { url: string, icon: string, children: } export const Sidebar = ({ cart, className = "" }: { cart: { cart: Cart, productData: ProductData } | null, className?: string }) => { + const sidebarRef = useRef(null); + const [isSidebarScrollable, setIsSidebarScrollable] = useState(false); + + useEffect((): (() => void) => { + const checkSidebarHeight = () => { + if (sidebarRef.current) { + setIsSidebarScrollable(sidebarRef.current.scrollHeight > sidebarRef.current.clientHeight); + } + } + checkSidebarHeight(); + window.addEventListener("resize", checkSidebarHeight); + + return () => { + window.removeEventListener("resize", checkSidebarHeight); + }; + }, []); + let path = location.pathname.trim(); if (path.endsWith("/")) { path = path.substring(0, path.length - 1); } - return