fix(router): pop to previous view, not the outlet layout URL#6533
Merged
Conversation
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.
Deploying flet-website-v2 with
|
| 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 |
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The Router's default
on_view_pophandler computed the non-modal pop target aschain[-2].resolved_path. When the chain contains anoutlet=Truelayout 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, notchain[-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— extendtest_nested_outlet_viewsto pop back to Home and re-navigate; add a navigation-idempotency step totest_nested_routes.Test plan
pytest tests/test_router_pop.py tests/test_router_modal.py tests/test_router_recursive.py— 18 passedtest_nested_outlet_viewsintegration test (Flutter harness) — passed with the new back-to-Home + re-navigate stepstest_nested_routesintegration test — passed with the idempotency steptest_router.pyintegration suite — 17 passed; the one error (test_featured_views) was a startup flake that passes in isolation and is unrelated to this changeSummary 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:
Tests: