Skip to content
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

[v17] [Web] Add sidenav highlight support for children of features #51569

Merged
merged 1 commit into from
Jan 29, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion web/packages/teleport/src/Login/useLogin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,6 @@ export type State = ReturnType<typeof useLogin> & {
* moveToFront returns a copy of an array with the element that matches the condition to the front of it.
*/
function moveToFront<T>(arr: T[], condition: (item: T) => boolean): T[] {
console.log(arr);
const copy = [...arr];
const index = copy.findIndex(condition);

Expand Down
9 changes: 8 additions & 1 deletion web/packages/teleport/src/Navigation/Navigation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ function getNavSubsectionForRoute(
features: TeleportFeature[],
route: history.Location<unknown> | Location
): NavigationSubsection {
const feature = features
let feature = features
.filter(feature => Boolean(feature.route))
.find(feature =>
matchPath(route.pathname, {
Expand All @@ -197,6 +197,13 @@ function getNavSubsectionForRoute(
})
);

// If this is a child feature, use its parent as the subsection instead.
// We do this because children of features don't appear as subsections in the sidenav, but we want to highlight
// their parent's subsection as active.
if (feature?.parent) {
feature = features.find(f => f instanceof feature.parent);
}

if (
!feature ||
(!feature.category && !feature.topMenuItem && !feature.navigationItem)
Expand Down
Loading