feat: ensure نوبت‌ها menu remains always expanded in the sidebar

This commit is contained in:
hamed
2026-07-23 15:03:47 +03:30
parent f218bc17ef
commit 9a776be13c
2 changed files with 12 additions and 7 deletions
+7 -2
View File
@@ -509,7 +509,12 @@ function NavItem({
const { icon: Icon, label, to, children } = item;
const location = useLocation();
const childActive = !!children?.some((c) => location.pathname === c.to);
const [open, setOpen] = useState(childActive);
// منوی «نوبت‌ها» همیشه باز می‌ماند و جمع نمی‌شود.
const alwaysOpen = !!children?.some((c) =>
c.to.startsWith("/admin/appointments"),
);
const [openState, setOpen] = useState(childActive);
const open = alwaysOpen || openState;
// منوی ساده — رفتار قبلی بدون تغییر.
if (!children || children.length === 0) {
@@ -553,7 +558,7 @@ function NavItem({
className={`nav-item${childActive ? " active" : ""}`}
aria-expanded={open}
title={!sidebarOpen ? label : undefined}
onClick={() => setOpen((o) => !o)}
onClick={() => !alwaysOpen && setOpen((o) => !o)}
style={{
width: "100%",
background: "none",