Skip to content

fix(router): pop to previous view, not the outlet layout URL#6533

Merged
FeodorFitsner merged 2 commits into
mainfrom
fix-router-nested-outlet-pop
May 29, 2026
Merged

fix(router): pop to previous view, not the outlet layout URL#6533
FeodorFitsner merged 2 commits into
mainfrom
fix-router-nested-outlet-pop

Conversation

@FeodorFitsner
Copy link
Copy Markdown
Contributor

@FeodorFitsner FeodorFitsner commented May 28, 2026

Summary

The Router's default on_view_pop handler computed the non-modal pop target as chain[-2].resolved_path. When the chain contains an outlet=True layout between two view entries (e.g. [Home, products-layout, ProductsList]), chain[-2] is the layout, whose resolved URL equals the leaf view's URL. Popping that view navigated to the URL already shown, leaving the page route stranded — so the next navigation to the same URL became a no-op.

Reproduced with examples/apps/router/nested_outlet_views: go Home → Products → back to Home → tap "Browse Products" again → nothing happens.

The fix computes the pop target from the chain's view entries (via _split_chain_into_view_levels), skipping outlet layouts and componentless grouping routes, so a pop lands on the actual previous view.

Changes

  • components/router.py — non-modal pop now targets the previous view entry, not chain[-2].
  • tests/test_router_pop.py — new unit tests for the pop-target computation (outlet-layout skip, nested case, single-view no-op).
  • integration_tests/.../test_router.py — extend test_nested_outlet_views to pop back to Home and re-navigate; add a navigation-idempotency step to test_nested_routes.

Test plan

  • pytest tests/test_router_pop.py tests/test_router_modal.py tests/test_router_recursive.py — 18 passed
  • test_nested_outlet_views integration test (Flutter harness) — passed with the new back-to-Home + re-navigate steps
  • test_nested_routes integration test — passed with the idempotency step
  • Full test_router.py integration suite — 17 passed; the one error (test_featured_views) was a startup flake that passes in isolation and is unrelated to this change

Summary by Sourcery

Ensure router view pops navigate to the correct previous view rather than leaving the page route stranded on an outlet layout URL.

Bug Fixes:

  • Fix non-modal router view pop to compute the target from view entries instead of the raw matched chain, so pops skip outlet layouts and grouping routes and land on the actual previous view.

Tests:

  • Add unit tests covering non-modal pop-target computation, including outlet-layout chains, nested product routes, and single-view stacks.
  • Extend nested router integration tests to verify back navigation returns to Home and that repeated navigations from Home remain effective after popping.

The default on_view_pop handler navigated to chain[-2].resolved_path,
which can be an outlet=True layout that shares the leaf view's URL.
Popping such a view navigated to the URL already shown, stranding the
page route so the next navigation to it was a no-op (e.g. in
nested_outlet_views: going back to Home then tapping "Browse Products"
did nothing).

Compute the pop target from the chain's view entries instead, skipping
outlet layouts and componentless grouping routes.

Add a test_router_pop unit test for the pop-target computation and
extend the nested_outlet_views integration test to cover popping back
to Home and re-navigating. Also add a navigation-idempotency step to
the nested_routes integration test.
Copy link
Copy Markdown
Contributor

@sourcery-ai sourcery-ai Bot left a comment

Choose a reason for hiding this comment

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

We've reviewed this pull request using the Sourcery rules engine

@cloudflare-workers-and-pages
Copy link
Copy Markdown

cloudflare-workers-and-pages Bot commented May 28, 2026

Deploying flet-website-v2 with  Cloudflare Pages  Cloudflare Pages

Latest commit: 1a87d1c
Status: ✅  Deploy successful!
Preview URL: https://d9f88ba3.flet-website-v2.pages.dev
Branch Preview URL: https://fix-router-nested-outlet-pop.flet-website-v2.pages.dev

View logs

@FeodorFitsner FeodorFitsner added this to the 0.85.3 milestone May 28, 2026
Bump the Dart packages/flet/pubspec.yaml to 0.85.3 (Python packages take
their version from CI at release time) and refresh client/pubspec.lock.

Add 0.85.3 changelog sections: a Router view-pop bug fix (#6533) in the
root CHANGELOG, and a no-Dart-changes coordination note in
packages/flet/CHANGELOG.md.
@FeodorFitsner FeodorFitsner merged commit bd0ca05 into main May 29, 2026
72 of 82 checks passed
@FeodorFitsner FeodorFitsner deleted the fix-router-nested-outlet-pop branch May 29, 2026 18:40
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

Successfully merging this pull request may close these issues.

1 participant