-
Notifications
You must be signed in to change notification settings - Fork 112
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bug fix on accordion active item #276
Conversation
for more information, see https://pre-commit.ci
Signed-off-by: Anna Xiong <anna.xiong@quantumblack.com> Co-authored-by: Maximilian Schulz <83698606+maxschulz-COL@users.noreply.github.com> Co-authored-by: Antony Milne <49395058+antonymilne@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Works well - thanks for fixing! 👍
@nadijagraca - for the next time it would be great if you could add some example code snippet to see that the relevant changes work. I wasn't quite sure what I had to test first 😄
For the next reviewer - replace the navigation in the example demo with:
navigation=vm.Navigation(
nav_selector=vm.NavBar(
items=[
vm.NavLink(label="Homepage", pages=["Homepage"], icon="Home"),
vm.NavLink(
label="Analysis",
pages={"Title 1": ["Variable Analysis", "Benchmark Analysis"],
"Title 2": ["Continent Summary", "Relationship Analysis"]},
icon="Stacked Bar Chart",
),
]
),
),
Then navigate to relationship-analysis either via clicking on the card on the homepage or by directly changing the path in the URL. What you should see is that the accordion opens accordingly (opens where active page is)
@nadijagraca @l0uden - will we add screenshots to test this? or do the unit tests cover this use case sufficiently?
vizro-core/changelog.d/20240123_103311_nadija_ratkusic_graca_accordion_active_item.md
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Really nice fix! I didn't test it out but it looks great, thank you for doing it 👍
However, I think there might be a minor bug in it. In this code:
next(
page_group for page_group, page_members in self.pages.items() if active_page_id in page_members
)
if active_page_id in page_members
is always False
then this will turn into next
of an empty dictionary, which will raise StopIteration
and crash. Try this out:
next(x for x, y in dict(a=1).items() if x == "b")
What I'm not sure about is whether this case can ever occur in practice? If I type the URL to a page that doesn't exist in the navigation then is it possible it would trigger this error?
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Alexey Snigir <35569332+l0uden@users.noreply.github.com> Co-authored-by: Li Nguyen <90609403+huong-li-nguyen@users.noreply.github.com>
Signed-off-by: Anna Xiong <anna.xiong@quantumblack.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Anna Xiong <anna.xiong@quantumblack.com> Co-authored-by: Li Nguyen <90609403+huong-li-nguyen@users.noreply.github.com> Co-authored-by: petar-qb <petar_pejovic@external.mckinsey.com> Co-authored-by: Antony Milne <49395058+antonymilne@users.noreply.github.com> Co-authored-by: Maximilian Schulz <83698606+maxschulz-COL@users.noreply.github.com> Co-authored-by: huong-li-nguyen <huong_li_nguyen@mckinsey.com> Co-authored-by: Alexey Snigir <35569332+l0uden@users.noreply.github.com>
Description
Fixing bug on accordion active item:
What to test:
If relevant accordion item opens when navigating from homepage or by typing path in browser.
Notice
I acknowledge and agree that, by checking this box and clicking "Submit Pull Request":