Skip to content

fix(navigation): clamp navigateViewGroup index before PageController.jumpToPage#2238

Draft
cursor[bot] wants to merge 1 commit into
mainfrom
cursor/critical-bug-identification-0103
Draft

fix(navigation): clamp navigateViewGroup index before PageController.jumpToPage#2238
cursor[bot] wants to merge 1 commit into
mainfrom
cursor/critical-bug-identification-0103

Conversation

@cursor
Copy link
Copy Markdown

@cursor cursor Bot commented May 26, 2026

Description

Fixes a crash when navigateViewGroup is invoked with a viewIndex outside the current ViewGroup tab range. PageController.jumpToPage asserts when the index is invalid; bottom navigation ViewGroups with reloadView: false supply a PageController from PageGroupWidget, 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 navigateViewGroup actions.

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update
  • Refactoring (no functional changes)

What Has Changed

  • In NavigateViewGroupAction.execute, resolve viewIndex through safeViewGroupPayloadIndex using the nearest PageGroup ancestor’s menu.menuItems.length, then pass that index to jumpToPage and viewGroupNotifier.updatePage.

How to Test

  1. From modules/ensemble, run flutter test test/safe_view_group_payload_index_test.dart (covers the clamp helper used here).
  2. Manual: bottom-nav ViewGroup with at least two tabs, call navigateViewGroup with viewIndex larger than the last tab index; the app should land on the last tab instead of crashing.

Screenshots / Videos

N/A

Checklist

  • I have run flutter analyze and addressed any new warnings
  • I have run flutter test and all tests pass
  • I have tested my changes on the relevant platform(s)
  • I have updated documentation if needed
  • My changes do not introduce new warnings or errors

Note: The automation environment did not have the Flutter SDK on PATH, so flutter analyze / flutter test were not executed here. Please run them locally per AGENTS.md.

Duplicate check

This PR reuses existing safeViewGroupPayloadIndex from page_group.dart (already unit-tested) instead of introducing a duplicate clamp helper.

Open in Web View Automation 

…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>
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