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={