-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
fix: only show active router link styles on parent page #22069
Changes from 2 commits
88f6e38
abc2817
da29d38
4327281
6c222ee
4c815fd
6945a3d
934591e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,12 +38,12 @@ | |
> | ||
<RouterLink | ||
v-for="item in navigation" | ||
v-slot="{ isActive }" | ||
v-slot="{ isExactActive }" | ||
:key="item.name" | ||
:to="item.href" | ||
> | ||
<SidebarNavigationRow | ||
:active="isActive" | ||
:active="isExactActive" | ||
Comment on lines
-46
to
+47
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I opted for a global change instead of a Specs-only exception to ensure all navigation links continue to have the same behavior. This means that if any of the other pages have links to a child view with a different URL (whether it be query params, pathname addition, etc) the navigation link will lose its active styles. This is intentional so that the user can more intuitively understand how to return to the parent page. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah I agree with doing this as the default. It's likely in the future, if we have nested router views, there would be cases where the exact route changes but the user is still "on" the main page. But I'm fine with not worrying about that till we get to that point. |
||
:icon="item.icon" | ||
:name="item.name" | ||
:is-nav-bar-expanded="isNavBarExpanded" | ||
|
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.
does it make sense to use a more specific selector like
cy.findAllByTestId('nav-link-spec')
just in case another link was added later?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.
Yes, good call!
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.
The update looks elegant!