From 4c6588bd8243de7848305e4294aebe4ed7d0f767 Mon Sep 17 00:00:00 2001 From: "pavel.malko" Date: Thu, 2 May 2024 12:41:03 +0300 Subject: [PATCH] fix: prefer return child path --- ckanext/nswdesignsystem/helpers.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ckanext/nswdesignsystem/helpers.py b/ckanext/nswdesignsystem/helpers.py index e4488b3..8228bd4 100644 --- a/ckanext/nswdesignsystem/helpers.py +++ b/ckanext/nswdesignsystem/helpers.py @@ -47,14 +47,14 @@ def nswdesignsystem_get_active_path(links: Iterable[types.NavDict], current: str def _search_current_path(links: Iterable[types.NavDict], current: str) -> list[int]: for idx, item in enumerate(links): - # endswith bypass root-path - if item["href"].endswith(current): - return [idx] - if "subnav" in item: if path := _search_current_path(item["subnav"]["children"], current): return [idx] + path + # endswith return root-path + if item["href"].endswith(current): + return [idx] + return [] def nswdesignsystem_demo_code(component: str) -> str: