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

AutoRouteGuard always called in all nested navigation when applied to initial child root #2131

Open
jonpittock opened this issue Jan 14, 2025 · 0 comments

Comments

@jonpittock
Copy link
Contributor

jonpittock commented Jan 14, 2025

With this setup:

AutoRoute(
  path: '/',
  page: SectionShellRoute.page,
  children: <AutoRoute>[
    RedirectRoute(
      path: '',
      redirectTo: 'protected',
    ),

    AutoRoute(
      path: 'protected',
      page: ProtectedScreenRoute.page,
      guards: <AutoRouteGuard>[
        CustomAuthenticatedGuard(),
      ],
    ),

    AutoRoute(
      path: 'unprotected',
      page: UnprotectedScreenRoute.page,
    ),

The unprotected route will seem to always apply the initial child route guard. You can see I have clearly defined which routes should use guards, but yet it ignores this. Instead, applying to everything within the parent shell.

If I remove the guard, of course I can then access!

Is this a bug? I have looked through issues and documentation and there is nothing describing the expectated behaviour.

@jonpittock jonpittock changed the title AutoRouteGuard in nested navigation when applied to initial child root AutoRouteGuard always called in all nested navigation when applied to initial child root Jan 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant