From aaf0b802442d6880b4ef5083e43f13ca8bee7d07 Mon Sep 17 00:00:00 2001 From: Kirill Zhumarin Date: Sat, 9 Aug 2025 16:26:07 +0000 Subject: [PATCH] fix opening drawer links on nav --- src/components/App/Drawer.tsx | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/components/App/Drawer.tsx b/src/components/App/Drawer.tsx index 71bda5e..efa7cff 100644 --- a/src/components/App/Drawer.tsx +++ b/src/components/App/Drawer.tsx @@ -1,4 +1,4 @@ -import { Component, createMemo, createSignal, For, JSX, ParentComponent, Show } from "solid-js"; +import { Component, createEffect, createMemo, createSignal, For, JSX, ParentComponent, Show } from "solid-js"; import { A, useMatch } from "@solidjs/router"; import { Box, Drawer, List, ListItemButton, ListItemIcon, ListItemText, Toolbar, useMediaQuery } from '@suid/material'; import ScreenshotIcon from '@suid/icons-material/Screenshot'; @@ -42,7 +42,7 @@ type DrawerLinkProps = { export const DrawerLink: Component = (props) => { const isSelected = () => props.url != null && matchURL(props.url); - const isNestedSelected = () => { + const isNestedSelected = createMemo(() => { if (props.sublinks) { for (const sublink of props.sublinks) { if (sublink.url && matchURL(sublink.url)) @@ -50,10 +50,16 @@ export const DrawerLink: Component = (props) => { } } return false; - }; + }); const [isOpen, setIsOpen] = createSignal(isNestedSelected()); const depth = () => props.depth ?? 1; + createEffect(() => { + // Update on navigation + if (isNestedSelected()) + setIsOpen(true); + }); + return ( 0} fallback={