Skip to content

Commit

Permalink
Merge pull request #1 from PavloMalko/fix-child-search
Browse files Browse the repository at this point in the history
fix: prefer return child path
  • Loading branch information
smotornyuk committed May 6, 2024
2 parents a9237f6 + 4c6588b commit 3d65416
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions ckanext/nswdesignsystem/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 3d65416

Please sign in to comment.