Skip to content

[web] Popping a nameless route should preserve the correct route name #173652

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

Merged
merged 2 commits into from
Aug 14, 2025

Conversation

mdebbar
Copy link
Contributor

@mdebbar mdebbar commented Aug 12, 2025

Fixes #173356

@mdebbar mdebbar requested a review from chunhtai August 12, 2025 21:08
@github-actions github-actions bot added engine flutter/engine repository. See also e: labels. platform-web Web applications specifically labels Aug 12, 2025
Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a 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 addresses an issue where popping a nameless route on the web did not preserve the URL of the previous named route. The fix involves introducing _currentRouteName to correctly track and restore the route name. The implementation is solid, simplifying the existing logic and adding a specific test case to validate the correction. The changes are well-executed and effectively resolve the bug.

Copy link
Contributor

@chunhtai chunhtai left a comment

Choose a reason for hiding this comment

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

LGTM, just some minor comment

Comment on lines 259 to 260
final String path = currentPath;
if (!_isFlutterEntry(domWindow.history.state)) {
_currentRouteName = path;
Copy link
Contributor

Choose a reason for hiding this comment

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

_currentRouteName = currentPath

@@ -303,11 +313,11 @@ class SingleEntryBrowserHistory extends BrowserHistory {
@override
void setRouteName(String? routeName, {Object? state, bool replace = false}) {
if (urlStrategy != null) {
_setupFlutterEntry(urlStrategy!, replace: true, path: routeName);
_currentRouteName = routeName ?? currentPath;
Copy link
Contributor

Choose a reason for hiding this comment

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

i think routeName will never be null given since routeUpdated method has been deprecated for ages.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do you think it's safe to remove the entire routeUpdated handler:

case 'routeUpdated': // deprecated
assert(arguments != null);
await _useSingleEntryBrowserHistory();
browserHistory.setRouteName(arguments!.tryString('routeName'));
return true;

Copy link
Contributor

Choose a reason for hiding this comment

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

yes, I think so, it has not been used since we have introduced Router. I forgot to clean it up

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, I'll do this cleanup in a follow up PR.

@@ -293,7 +295,7 @@ void testMain() {
expect(spy.messages[0].methodName, 'pushRoute');
expect(spy.messages[0].methodArguments, '/page3');
spy.messages.clear();
// 2. The framework sends a `routePushed` platform message.
// 2. The framework sends a `routeUpdated` platform message.
Copy link
Contributor

Choose a reason for hiding this comment

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

not something need to be address in this pr, routeUpdated is not used by framework for a long time now

await implicitView.debugInitializeHistory(strategy, useSingle: true);

// Go to a named route.
await routeUpdated('/named-route');
Copy link
Contributor

Choose a reason for hiding this comment

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

let's use routeInformationUpdated for accuracy

@mdebbar mdebbar added the autosubmit Merge PR when tree becomes green via auto submit App label Aug 13, 2025
@auto-submit auto-submit bot added this pull request to the merge queue Aug 13, 2025
Merged via the queue into flutter:master with commit f83d8cf Aug 14, 2025
180 checks passed
@flutter-dashboard flutter-dashboard bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Aug 14, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Aug 14, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Aug 14, 2025
@mdebbar mdebbar deleted the history_nameless_route branch August 14, 2025 16:41
auto-submit bot pushed a commit to flutter/packages that referenced this pull request Aug 14, 2025
flutter/flutter@34c2a3b...f4334d2

2025-08-14 engine-flutter-autoroll@skia.org Roll Dart SDK from 9b4691f35139 to 214a7f829913 (2 revisions) (flutter/flutter#173769)
2025-08-14 engine-flutter-autoroll@skia.org Roll Skia from b3e86773dae1 to dca5f05fee87 (4 revisions) (flutter/flutter#173763)
2025-08-14 engine-flutter-autoroll@skia.org Roll Dart SDK from 73153bdc1459 to 9b4691f35139 (3 revisions) (flutter/flutter#173755)
2025-08-14 engine-flutter-autoroll@skia.org Roll Skia from 5852eddfd404 to b3e86773dae1 (1 revision) (flutter/flutter#173750)
2025-08-14 azat24680@gmail.com Allow empty initial time when using text input mode in showTimePicker dialog (flutter/flutter#172847)
2025-08-13 engine-flutter-autoroll@skia.org Roll Skia from 525e2bf80559 to 5852eddfd404 (2 revisions) (flutter/flutter#173740)
2025-08-13 mdebbar@google.com [web] Popping a nameless route should preserve the correct route name (flutter/flutter#173652)
2025-08-13 ahmedsameha1@gmail.com Make sure that a ChoiceChip doesn't crash in 0x0 environment (flutter/flutter#173322)
2025-08-13 bkonyi@google.com [ Tool ] Fix missing import for widget_preview.dart (flutter/flutter#173731)
2025-08-13 engine-flutter-autoroll@skia.org Roll Skia from f7fdda3cd0e6 to 525e2bf80559 (7 revisions) (flutter/flutter#173727)
2025-08-13 matanlurey@users.noreply.github.com Do not include `:unittests` unless `enable_unittests` (flutter/flutter#173729)
2025-08-13 engine-flutter-autoroll@skia.org Roll Packages from 08a9b2c to 6cb9113 (1 revision) (flutter/flutter#173726)
2025-08-13 56157868+albinpk@users.noreply.github.com fix: selected date decorator renders outside PageView in `DatePickerDialog` dialog (flutter/flutter#171718)
2025-08-13 bkonyi@google.com [ Widget Preview ] Add `--machine` mode (flutter/flutter#173654)
2025-08-13 ahmedsameha1@gmail.com Make sure that a Chip doesn't crash in 0x0 environment (flutter/flutter#173245)
2025-08-13 returnymgstokh@icloud.com feat: Cupertino sheet implement upward stretch on full sheet (flutter/flutter#168547)
2025-08-13 131446187+TheLastFlame@users.noreply.github.com Fix visual overlap of transparent routes barrier when using FadeForwardsPageTransitionsBuilder (flutter/flutter#167032)
2025-08-13 32538273+ValentinVignal@users.noreply.github.com Fix `ChipThemeData` lerp for `BorderSide` (flutter/flutter#173160)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-packages
Please CC louisehsu@google.com,stuartmorgan@google.com on the revert to ensure that a human
is aware of the problem.

To file a bug in Packages: https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://issues.skia.org/issues/new?component=1389291&template=1850622

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
github-merge-queue bot pushed a commit that referenced this pull request Aug 14, 2025
ksokolovskyi pushed a commit to ksokolovskyi/flutter that referenced this pull request Aug 19, 2025
WillBLogical pushed a commit to WillBLogical/packages that referenced this pull request Aug 20, 2025
…r#9807)

flutter/flutter@34c2a3b...f4334d2

2025-08-14 engine-flutter-autoroll@skia.org Roll Dart SDK from 9b4691f35139 to 214a7f829913 (2 revisions) (flutter/flutter#173769)
2025-08-14 engine-flutter-autoroll@skia.org Roll Skia from b3e86773dae1 to dca5f05fee87 (4 revisions) (flutter/flutter#173763)
2025-08-14 engine-flutter-autoroll@skia.org Roll Dart SDK from 73153bdc1459 to 9b4691f35139 (3 revisions) (flutter/flutter#173755)
2025-08-14 engine-flutter-autoroll@skia.org Roll Skia from 5852eddfd404 to b3e86773dae1 (1 revision) (flutter/flutter#173750)
2025-08-14 azat24680@gmail.com Allow empty initial time when using text input mode in showTimePicker dialog (flutter/flutter#172847)
2025-08-13 engine-flutter-autoroll@skia.org Roll Skia from 525e2bf80559 to 5852eddfd404 (2 revisions) (flutter/flutter#173740)
2025-08-13 mdebbar@google.com [web] Popping a nameless route should preserve the correct route name (flutter/flutter#173652)
2025-08-13 ahmedsameha1@gmail.com Make sure that a ChoiceChip doesn't crash in 0x0 environment (flutter/flutter#173322)
2025-08-13 bkonyi@google.com [ Tool ] Fix missing import for widget_preview.dart (flutter/flutter#173731)
2025-08-13 engine-flutter-autoroll@skia.org Roll Skia from f7fdda3cd0e6 to 525e2bf80559 (7 revisions) (flutter/flutter#173727)
2025-08-13 matanlurey@users.noreply.github.com Do not include `:unittests` unless `enable_unittests` (flutter/flutter#173729)
2025-08-13 engine-flutter-autoroll@skia.org Roll Packages from 08a9b2c to 6cb9113 (1 revision) (flutter/flutter#173726)
2025-08-13 56157868+albinpk@users.noreply.github.com fix: selected date decorator renders outside PageView in `DatePickerDialog` dialog (flutter/flutter#171718)
2025-08-13 bkonyi@google.com [ Widget Preview ] Add `--machine` mode (flutter/flutter#173654)
2025-08-13 ahmedsameha1@gmail.com Make sure that a Chip doesn't crash in 0x0 environment (flutter/flutter#173245)
2025-08-13 returnymgstokh@icloud.com feat: Cupertino sheet implement upward stretch on full sheet (flutter/flutter#168547)
2025-08-13 131446187+TheLastFlame@users.noreply.github.com Fix visual overlap of transparent routes barrier when using FadeForwardsPageTransitionsBuilder (flutter/flutter#167032)
2025-08-13 32538273+ValentinVignal@users.noreply.github.com Fix `ChipThemeData` lerp for `BorderSide` (flutter/flutter#173160)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-packages
Please CC louisehsu@google.com,stuartmorgan@google.com on the revert to ensure that a human
is aware of the problem.

To file a bug in Packages: https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://issues.skia.org/issues/new?component=1389291&template=1850622

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
SydneyBao pushed a commit to SydneyBao/flutter that referenced this pull request Aug 22, 2025
SydneyBao pushed a commit to SydneyBao/flutter that referenced this pull request Aug 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
engine flutter/engine repository. See also e: labels. platform-web Web applications specifically
Projects
None yet
Development

Successfully merging this pull request may close these issues.

The showDialog bug prevents Flutter from being applied to production-level web applications.
2 participants