Skip to content

Fix selection registration for hidden overlay entries - #189713

Draft
mvincentong wants to merge 3 commits into
flutter:masterfrom
mvincentong:fix-selectable-region-background-routes
Draft

mvincentong wants to merge 3 commits into
flutter:masterfrom
mvincentong:fix-selectable-region-background-routes

Conversation

@mvincentong

@mvincentong mvincentong commented Jul 19, 2026 •

Copy link
Copy Markdown
Contributor

OverlayEntrys that remain mounted behind an opaque entry still build their
subtrees to preserve state, but _RenderTheater skips their layout and paint.
Those hidden subtrees were still inheriting the ancestor selection registrar,
so their selectables could be registered and compared before they had been laid
out. That could trigger the RenderParagraph.debugNeedsLayout assertion while
selection ordering was flushed.

This wraps only hidden maintained entries in SelectionContainer.disabled when
an ancestor selection registrar is present. Onstage entries continue to inherit
the existing registrar, and the route subtree remains mounted throughout so
its state is preserved. The public selection registrar API is unchanged.

Fixes #119772.

Tests:

  • ./bin/flutter test --no-pub packages/flutter/test/widgets/selectable_region_test.dart
  • ../../bin/flutter test --no-pub --platform chrome test/widgets/selectable_region_test.dart --plain-name "ignores selection content in background Navigator pages" (from packages/flutter)
  • ./bin/flutter test --no-pub packages/flutter/test/widgets/selection_container_test.dart packages/flutter/test/widgets/overlay_test.dart
  • ./bin/flutter analyze --no-pub packages/flutter/lib/src/widgets/overlay.dart packages/flutter/lib/src/widgets/selection_container.dart packages/flutter/test/widgets/selectable_region_test.dart
  • ./bin/dart format --output=none --set-exit-if-changed packages/flutter/lib/src/widgets/overlay.dart packages/flutter/lib/src/widgets/selection_container.dart packages/flutter/test/widgets/selectable_region_test.dart
  • git diff --check

Risk:

  • Two focused framework/test files are changed; no generated output is included.
  • Existing SelectionContainer.disabled behavior is used to exclude hidden overlay entries from selection while preserving their mounted subtree. No public API is changed.

Pre-launch Checklist

If you need help, consider asking for advice on the #hackers-new channel on Discord.

If this change needs to override an active code freeze, provide a comment explaining why. The Flutter team can override the code freeze workflow. See pinned issues for current guidance.

Note: The Flutter team is currently trialing the use of Gemini Code Assist for GitHub. Comments from the gemini-code-assist bot should not be taken as authoritative feedback from the Flutter team. If you find comments useful, you may update the code accordingly, but if you are unsure or disagree, wait for a Flutter team member's review.

@github-actions github-actions Bot added the framework flutter/packages/flutter repository. See also f: labels. label Jul 19, 2026
@mvincentong
mvincentong force-pushed the fix-selectable-region-background-routes branch from 99ff3f2 to 9c901c7 Compare August 1, 2026 12:38
@mvincentong

Copy link
Copy Markdown
Contributor Author

Tightened the fix in c0a82e866f: hidden maintained entries now use the existing SelectionContainer.disabled path, while onstage entries inherit the registrar; the public selection API is unchanged. The focused regression, affected widget suites, and full selectable-region suite remain green.

@mvincentong

Copy link
Copy Markdown
Contributor Author

Also verified the regression in the package-relative Chrome harness: ../../bin/flutter test --no-pub --platform chrome test/widgets/selectable_region_test.dart --plain-name "ignores selection content in background Navigator pages" passes.

@Piinks

Piinks commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

Hey @mvincentong! Is this still something you want to work on? Draft PRs are not typically reviewed, you can mark it ready for review when it is. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

framework flutter/packages/flutter repository. See also f: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

debugNeedsLayout assertion failed in background page under SelectableRegion

2 participants