Uh oh!
There was an error while loading. Please reload this page.
Preserve SelectableRegion scope across context menu rebuilds - #186553
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces a GlobalKey to SelectableRegionState to maintain the SelectableRegionSelectionStatusScope subtree across rebuilds. It also adds a widget test to ensure SelectableRegion can rebuild on the web after disabling the browser context menu. Feedback indicates that the new private GlobalKey should include public-quality documentation and a debugLabel to align with the Flutter style guide.
Uh oh!
There was an error while loading. Please reload this page.
01851b9 to
4007a07CompareUh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
| expect(tester.takeException(), isNull); | ||
| } | ||
| await updateContextMenu(BrowserContextMenu.disableContextMenu()); |
There was a problem hiding this comment.
nit: I'd add a pump between each of these, and end with a pumpAndSettle.
There was a problem hiding this comment.
Thanks for addressing this, I think it would be easier to read if this just calls BrowserContextMenu.disable/enable() directly with a pump in between rather than using this helper method.
Uh oh!
There was an error while loading. Please reload this page.
Renzo-Olivares
left a comment
There was a problem hiding this comment.
Left a few small comments.
Renzo-Olivares
commented
Jul 16, 2026
Hi @mvincentong, friendly ping is this something you still want to work on? |
mvincentong
commented
Jul 19, 2026
Renzo-Olivares
left a comment
There was a problem hiding this comment.
LGTM modulo my one comment. This will need a secondary review before landing.
| expect(tester.takeException(), isNull); | ||
| } | ||
| await updateContextMenu(BrowserContextMenu.disableContextMenu()); |
There was a problem hiding this comment.
Thanks for addressing this, I think it would be easier to read if this just calls BrowserContextMenu.disable/enable() directly with a pump in between rather than using this helper method.
Piinks
commented
Jul 21, 2026
I think this will also need a rebase to resolve the ci failure. |
96b9f77 to
58ae119Comparea2e033a to
51ed117CompareUh oh!
There was an error while loading. Please reload this page.
SelectableRegionconditionally wraps its selection subtree inPlatformSelectableRegionContextMenuon desktop web. WhenBrowserContextMenu.enabledchanges, that wrapper can be removed while the existing rootSelectionContaineris still registered, causing a replacement container to register before the old one unregisters.This keeps the selection status scope keyed from
SelectableRegionState, so the selection subtree is reparented across the optional wrapper change instead of recreated. The browser regression covers enable/disable transitions with the widgets-layer test harness and current selection controls.Fixes#186459.
Tests:
../../bin/flutter test --no-pub --platform chrome test/widgets/selectable_region_context_menu_test.dart./bin/flutter analyze --no-pub packages/flutter/lib/src/widgets/selectable_region.dart packages/flutter/test/widgets/selectable_region_context_menu_test.dart./bin/dart format --output=none --set-exit-if-changed packages/flutter/test/widgets/selectable_region_context_menu_test.dartgit diff --checkPre-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 code freeze workflow can be overridden by code reviewers. See pinned issues for any active code freezes with guidance.
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.