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

Add logic in get active route #33370

Merged
merged 9 commits into from
Jan 2, 2024
Merged
Changes from 6 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
9 changes: 5 additions & 4 deletions src/libs/Navigation/Navigation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,9 @@ function getDistanceFromPathInRootNavigator(path: string): number {
/** Returns the current active route */
function getActiveRoute(): string {
const currentRoute = navigationRef.current && navigationRef.current.getCurrentRoute();
if (!currentRoute?.name) {
return '';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's add this back


if (currentRoute?.path) {
return currentRoute.path;
}

const routeFromState = getPathFromState(navigationRef.getRootState(), linkingConfig.config);
Expand All @@ -114,8 +115,8 @@ function getActiveRoute(): string {
* @return is active
*/
function isActiveRoute(routePath: Route): boolean {
// We remove First forward slash from the URL before matching
return getActiveRoute().substring(1) === routePath;
// On web, we remove First forward slash from the URL before matching
return getActiveRoute().startsWith('/') ? getActiveRoute().substring(1) === routePath : getActiveRoute() === routePath;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this change needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On native, currentRoute.path doesn't have a first forward slash
Screenshot 2023-12-25 at 11 15 24

}

/**
Expand Down