-
Notifications
You must be signed in to change notification settings - Fork 3.6k
[go_router] Fixes an issue where onEnter blocking causes navigation stack loss (stale state restoration)
#10476
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
base: main
Are you sure you want to change the base?
Conversation
…o 17.0.1 This commit fixes an issue where `onEnter` blocking caused navigation stack loss due to stale state restoration. It ensures that `currentConfiguration` is used instead of the internal cache when navigation is blocked. - Bumps version to 17.0.1 - Updates CHANGELOG.md - Adds regression test in on_enter_test.dart Fixes flutter/flutter#178853
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request effectively addresses an issue where onEnter blocking could cause stale state restoration in the navigation stack. The fix, which prioritizes the routerDelegate.currentConfiguration when a navigation is blocked, is logical and correctly implemented. The inclusion of a targeted test case that reproduces the bug is excellent and ensures the fix is robust. The version and changelog updates are also correctly handled. I have a couple of minor suggestions to improve code clarity and conciseness.
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
| }, | ||
| onCanNotEnter: () { | ||
| // If blocked, "stay" on last successful match if available. | ||
| // If blocked, stay on the current route by restoring the last known good configuration. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This new check looks good to me!
also I think it's ok to remove the old check in line 171 for _lastMatchList if we are checking "router.routerDelegate.currentConfiguration" already?
hannah-hyj
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
chunhtai
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
|
autosubmit label was removed for flutter/packages/10476, because Pull request flutter/packages/10476 is not in a mergeable state. |
Replace this paragraph with a description of what this PR is changing or adding, and why. Consider including before/after screenshots.
List which issues are fixed by this PR. You must list at least one issue.
Fixes flutter/flutter#178853
Pre-Review Checklist
[shared_preferences]pubspec.yamlwith an appropriate new version according to the pub versioning philosophy, or I have commented below to indicate which version change exemption this PR falls under1.CHANGELOG.mdto add a description of the change, following repository CHANGELOG style, or I have commented below to indicate which CHANGELOG exemption this PR falls under1.///).If you need help, consider asking for advice on the #hackers-new channel on Discord.
Note: The Flutter team is currently trialing the use of Gemini Code Assist for GitHub. Comments from the
gemini-code-assistbot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed.Footnotes
Regular contributors who have demonstrated familiarity with the repository guidelines only need to comment if the PR is not auto-exempted by repo tooling. ↩ ↩2 ↩3