Skip to content

[go_router] Expose Navigator clipBehavior on ShellRoute and StatefulShellBranch - #12646

Merged
auto-submit[bot] merged 5 commits into
flutter:mainfrom
m1roxx:go-router-shell-clip-behavior
Sep 30, 2026
Merged

auto-submit[bot] merged 5 commits into
flutter:mainfrom
m1roxx:go-router-shell-clip-behavior

Conversation

@m1roxx

@m1roxx m1roxx commented Aug 27, 2026 •

Copy link
Copy Markdown
Contributor

The Navigator that ShellRoute and each StatefulShellBranch build always clipped its contents, with no way to opt out. A sub-route could therefore not paint outside the bounds the shell lays out for it — a box shadow or an overflowing menu gets cut off (see the samples in the issue).

This adds a clipBehavior parameter to ShellRoute and StatefulShellBranch that is forwarded to the Navigator each of them builds, as suggested by @chunhtai in flutter/flutter#131836 (comment).

It defaults to Clip.hardEdge, which is Navigator's own default, so existing behavior is unchanged. As noted in the issue discussion, setting Clip.none also lets route transition animations paint outside the shell's bounds; that trade-off is documented on the new clipBehavior doc comment so callers can make an informed choice.

StatefulShellBranch carries the parameter rather than StatefulShellRoute because each branch builds its own Navigator, which is how observers and restorationScopeId are already configured.

Fixes flutter/flutter#131836

Pre-Review Checklist

Footnotes

  1. 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

…hellBranch

Nested shell Navigators always clipped their contents, so a sub-route
could not paint outside the bounds the shell laid out for it (a box
shadow or an overflowing menu got cut off).

Adds a `clipBehavior` parameter to `ShellRoute` and `StatefulShellBranch`
that is forwarded to the `Navigator` each of them builds. It defaults to
`Clip.hardEdge`, which is the `Navigator` default, so existing behavior
is unchanged.

Branches configure this individually because each `StatefulShellBranch`
builds its own `Navigator`, matching how `observers` and
`restorationScopeId` already work.
@google-cla

google-cla Bot commented Aug 27, 2026

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@github-actions github-actions Bot added p: go_router triage-framework Should be looked at in framework triage labels Aug 27, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

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 adds a clipBehavior property to ShellRoute and StatefulShellBranch in go_router, which is forwarded to the nested Navigator to control whether sub-routes can paint outside the shell's bounds. The feedback suggests specifying the default value Clip.hardEdge directly in the NavigatorBuilder typedef to ensure that custom or mock implementations can statically resolve the default value correctly.

Comment thread packages/go_router/lib/src/route.dart Outdated
@m1roxx

m1roxx commented Aug 27, 2026

Copy link
Copy Markdown
Contributor Author

@googlebot I signed it!

@stuartmorgan-g stuartmorgan-g removed the triage-framework Should be looked at in framework triage label Sep 1, 2026
@stuartmorgan-g

Copy link
Copy Markdown
Collaborator

[x] I followed the version and CHANGELOG instructions, using semantic versioning and the repository CHANGELOG style, or I have commented below to indicate which documented exception this PR falls under1.

This package uses the batched release system, so the changelog and version changes here will need to be updated to use the batch process described in the linked docs. As noted there, we recommend using the package tooling rather than making the change manually.

Comment thread packages/go_router/CHANGELOG.md Outdated
@m1roxx

m1roxx commented Sep 3, 2026

Copy link
Copy Markdown
Contributor Author

Thanks! Moved the entry to pending_changelogs/ and reverted the direct CHANGELOG.md / pubspec.yaml edits.

I marked it version: major, because NavigatorBuilder is exported from go_router.dart and the added named parameter makes existing 6-parameter functions no longer assignable to it — so anyone constructing a ShellRouteContext with their own builder would break. There are no such call sites inside the repo.

If you would rather not take a breaking change for this, the alternative is to leave NavigatorBuilder untouched and have builder.dart resolve the clip behavior from the match instead — route.clipBehavior for a ShellRoute, or the branch whose navigatorKey matches for a StatefulShellRoute. That is fully non-breaking, but it type-switches on the route kind and would not extend to custom ShellRouteBase subclasses. Happy to go either way.

go_router opts into batch release in ci_config.yaml, so CHANGELOG.md and
the pubspec version must not be edited directly. Revert both and describe
the change in pending_changelogs instead.
@m1roxx
m1roxx force-pushed the go-router-shell-clip-behavior branch from bf1227a to 582fabb Compare September 3, 2026 06:56
@elliette

elliette commented Sep 3, 2026

Copy link
Copy Markdown
Member

Hi @m1roxx, thanks for working on this. Regarding you suggestion:

If you would rather not take a breaking change for this, the alternative is to leave NavigatorBuilder untouched and have builder.dart resolve the clip behavior from the match instead — route.clipBehavior for a ShellRoute, or the branch whose navigatorKey matches for a StatefulShellRoute. That is fully non-breaking, but it type-switches on the route kind and would not extend to custom ShellRouteBase subclasses. Happy to go either way.

That would definitely be preferred! Bumping to a major version carries unnecessary friction and ecosystem churn. Thank you!

@Piinks

Piinks commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

Yup, absolutely. We also just published a major version so we would also not want to do so again so soon.

Keep the NavigatorBuilder typedef and ShellRouteContext unchanged, and
resolve the clip behavior in builder.dart from the shell route and the
Navigator key instead, so the change stays additive.

Downgrade the pending changelog to a minor version.
@m1roxx

m1roxx commented Sep 4, 2026

Copy link
Copy Markdown
Contributor Author

Done — reworked to keep this non-breaking. NavigatorBuilder and ShellRouteContext are untouched; builder.dart now resolves the clip behavior from the shell route and the Navigator key, and the pending changelog is version: minor. The PR is purely additive now (+204/−0).

One correction to what I wrote above: the "would not extend to custom ShellRouteBase subclasses" caveat does not apply — ShellRouteBase only has a private constructor, so ShellRoute and StatefulShellRoute are the only possible cases.

@m1roxx

m1roxx commented Sep 9, 2026

Copy link
Copy Markdown
Contributor Author

@Piinks @elliette friendly ping — I reworked this on Sep 4 to address the review: NavigatorBuilder and ShellRouteContext are untouched, builder.dart resolves the clip behavior from the shell route and the Navigator key, and the pending changelog is version: minor. The change is purely additive now (+204/−0), so no major bump is needed. Ready for another look whenever you have time.

Comment thread packages/go_router/lib/src/builder.dart Outdated
Comment thread packages/go_router/lib/src/route.dart
Comment thread packages/go_router/pending_changelogs/shell_route_clip_behavior.yaml Outdated

@Piinks Piinks left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Could you also add Clip clipBehavior = Clip.hardEdge to ShellRouteData.$route and StatefulShellBranchData.$branch in packages/go_router/lib/src/route_data.dart and forward it to ShellRoute / StatefulShellBranch?

Comment thread packages/go_router/lib/src/route.dart
Comment thread packages/go_router/lib/src/builder.dart Outdated
@m1roxx

m1roxx commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor Author

@Piinks thanks for the review! Addressed everything in 919818f:

  • ShellRouteData.$route and StatefulShellBranchData.$branch now take Clip clipBehavior = Clip.hardEdge and forward it to ShellRoute / StatefulShellBranch, with tests.
  • The inline comments are answered in their threads (doc template, default on _CustomNavigator, debugFillProperties, changelog wording).

Ready for another look.

- Share the clipBehavior docs through a doc template
- Default _CustomNavigator.clipBehavior to Clip.hardEdge
- Include clipBehavior in ShellRoute.debugFillProperties
- Forward clipBehavior from ShellRouteData.$route and StatefulShellBranchData.$branch
- Shorten the pending changelog entry
…uter-shell-clip-behavior

# Conflicts:
#	packages/go_router/lib/src/builder.dart
@m1roxx
m1roxx force-pushed the go-router-shell-clip-behavior branch from 1dec4c1 to 0d00d94 Compare September 25, 2026 10:35

@Piinks Piinks left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM! Thank you for addressing all the review feedback and adding the $route / $branch forwarding and tests.

@Piinks Piinks added the CICD Run CI/CD label Sep 28, 2026
@elliette elliette added the autosubmit Merge PR when tree becomes green via auto submit App label Sep 30, 2026
@auto-submit
auto-submit Bot merged commit 738f6e5 into flutter:main Sep 30, 2026
14 checks passed
jesswrd pushed a commit to jesswrd/flutter that referenced this pull request Oct 1, 2026
…er#193641)

flutter/packages@0ba9a82...d5ec6db

2026-10-01 faheemabbas766@gmail.com [tool] Enforce README package table
order (flutter/packages#12316)
2026-09-30 jessiewong401@gmail.com [various] Allow plugin example apps
to build and test on JDK 25 (flutter/packages#13031)
2026-09-30 149176071+m1roxx@users.noreply.github.com [go_router] Expose
Navigator clipBehavior on ShellRoute and StatefulShellBranch
(flutter/packages#12646)
2026-09-30 stuartmorgan@google.com [google_maps_flutter] Convert unit
tests to Kotlin (flutter/packages#13072)
2026-09-30 36861262+QuncCccccc@users.noreply.github.com [material_ui]
Migrate M3 ListTile template to use new gen_defaults
(flutter/packages#13056)
2026-09-30 15619084+vashworth@users.noreply.github.com Allow tests to
use macOS 15.7 or macOS 26.6 (flutter/packages#13007)
2026-09-30 43054281+camsim99@users.noreply.github.com
[camera_android_camerax] Fix exposure offset setting error thrown when
canceled by a new request (flutter/packages#12582)
2026-09-30 engine-flutter-autoroll@skia.org Roll Flutter from
55b8f88 to d649d2b (27 revisions) (flutter/packages#13080)
2026-09-30 36861262+QuncCccccc@users.noreply.github.com [material_ui]
Migrate M3 InputDecorator template to use new gen_defaults
(flutter/packages#13024)
2026-09-30 tarrinneal@gmail.com [pigeon] Fix JNI/FFI typed data memory
lifetime bugs and update docs (flutter/packages#13061)
2026-09-30 43054281+camsim99@users.noreply.github.com
[camera_android_camerax] Correct `pre-push` skill version validation
logic (flutter/packages#12371)

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

To file a bug in Flutter:
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

autosubmit Merge PR when tree becomes green via auto submit App CICD Run CI/CD p: go_router

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[go_router] Expose Navigator.clipBehavior to ShellRoute

4 participants