fix(navigation): clamp navigateViewGroup index before PageController.jumpToPage#2238
Draft
cursor[bot] wants to merge 1 commit into
Draft
fix(navigation): clamp navigateViewGroup index before PageController.jumpToPage#2238cursor[bot] wants to merge 1 commit into
cursor[bot] wants to merge 1 commit into
Conversation
…jumpToPage NavigateViewGroupAction passed script-provided viewIndex directly to jumpToPage, which asserts when the index is outside the tab range (e.g. bottom nav with reloadView=false). Reuse safeViewGroupPayloadIndex with the ancestor PageGroup menu length so the notifier and PageController stay aligned. Co-authored-by: Sharjeel Yunus <sharjeelyunus@users.noreply.github.com>
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.
Description
Fixes a crash when
navigateViewGroupis invoked with aviewIndexoutside the current ViewGroup tab range.PageController.jumpToPageasserts when the index is invalid; bottom navigation ViewGroups withreloadView: falsesupply aPageControllerfromPageGroupWidget, so this path was reachable from app scripts.Related Issue
None filed. Same scenario as the previously closed draft #2220 (not merged). #2225 addressed stale indices when payloads shrink, not out-of-range indices on explicit
navigateViewGroupactions.Type of Change
What Has Changed
NavigateViewGroupAction.execute, resolveviewIndexthroughsafeViewGroupPayloadIndexusing the nearestPageGroupancestor’smenu.menuItems.length, then pass that index tojumpToPageandviewGroupNotifier.updatePage.How to Test
modules/ensemble, runflutter test test/safe_view_group_payload_index_test.dart(covers the clamp helper used here).navigateViewGroupwithviewIndexlarger than the last tab index; the app should land on the last tab instead of crashing.Screenshots / Videos
N/A
Checklist
flutter analyzeand addressed any new warningsflutter testand all tests passNote: The automation environment did not have the Flutter SDK on
PATH, soflutter analyze/flutter testwere not executed here. Please run them locally perAGENTS.md.Duplicate check
gh pr listandgh search prsfor navigateViewGroup / jumpToPage / clampViewGroupTabIndex. No open PR fixes thisNavigateViewGroupAction+jumpToPagepath. Open PRs fix(storage): defer binding updates until ensemble.storage.clear() completes #2231 (storage.clear ordering) and fix(upload): complete cancelAll when some uploads already finished #2235 (upload cancelAll loop) touch different code paths and root causes.viewIndexinNavigateViewGroupAction.cursor/critical-bug-identification-0103only.This PR reuses existing
safeViewGroupPayloadIndexfrompage_group.dart(already unit-tested) instead of introducing a duplicate clamp helper.