From 6ae1097a79678ba5187bbc39d114f2a2cdb0278e Mon Sep 17 00:00:00 2001 From: Tristan Holaday <40547442+TristanHoladay@users.noreply.github.com> Date: Fri, 1 Nov 2024 14:28:06 -0600 Subject: [PATCH 1/3] fix(ui): url updates from link clicks not showing current route in sidenav (#522) --- .../features/navigation/sidebar/component.svelte | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/ui/src/lib/features/navigation/sidebar/component.svelte b/ui/src/lib/features/navigation/sidebar/component.svelte index c2705d0ef..706545950 100644 --- a/ui/src/lib/features/navigation/sidebar/component.svelte +++ b/ui/src/lib/features/navigation/sidebar/component.svelte @@ -43,6 +43,20 @@ return route }) } + + // If link was clicked, updating url, but path is a child route that is currently not renendered + // we need to toggle the submenu to show the child route + function updateOnLinkClicks(path: string) { + for (const route of routes) { + if (path.includes(route.path) && !toggleSubmenus[route.path]) { + toggleSubmenus[route.path] = true + } + } + } + + $: if ($page.url.pathname) { + updateOnLinkClicks($page.url.pathname) + }