Skip to content

Conversation

@Renzo-Olivares
Copy link
Contributor

@Renzo-Olivares Renzo-Olivares commented Oct 10, 2025

This change fixes an issue where the flutter rendered menu would show up when ending a drag on a selection handle, even when the web context menu was enabled. This led to issues where both context menus would show up leading to a unfavorable experience.

Fixes #175114

Pre-launch Checklist

  • I read the [Contributor Guide] and followed the process outlined there for submitting PRs.
  • I read the [Tree Hygiene] wiki page, which explains my responsibilities.
  • I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement].
  • I signed the [CLA].
  • I listed at least one issue that this PR fixes in the description above.
  • I updated/added relevant documentation (doc comments with ///).
  • I added new tests to check the change I am making, or this PR is [test-exempt].
  • I followed the [breaking change policy] and added [Data Driven Fixes] where supported.
  • All existing and new tests are passing.

@github-actions github-actions bot added a: text input Entering text in a text field or keyboard related problems framework flutter/packages/flutter repository. See also f: labels. labels Oct 10, 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 correctly fixes an issue where the Flutter-rendered context menu would appear on top of the native web context menu after a selection handle drag. The approach of centralizing the toolbar showing logic in _showToolbar and using a _webContextMenuEnabled getter is clean.

I've left a couple of comments: one suggestion to simplify the code by removing a now-redundant conditional block, and another pointing out a potential bug in the new handlesAreVisible getter which could cause issues with handle visibility checks.

@Renzo-Olivares Renzo-Olivares force-pushed the sr-double-context-menu-fix branch from 88af992 to 80b1da5 Compare October 10, 2025 19:04
@Renzo-Olivares Renzo-Olivares changed the title SelectableRegion should not show flutter rendered context menu when web context menu is enabled SelectableRegion should not show flutter rendered context menu when web context menu is enabled Oct 10, 2025
@github-actions github-actions bot removed the a: text input Entering text in a text field or keyboard related problems label Oct 12, 2025
@Renzo-Olivares Renzo-Olivares force-pushed the sr-double-context-menu-fix branch from 244f2b4 to 486de9b Compare October 12, 2025 09:12
_selectionOverlay != null &&
(_selectionOverlay!.isDraggingStartHandle || _selectionOverlay!.isDraggingEndHandle);
if (widget.selectionControls is! TextSelectionHandleControls) {
if (!draggingHandles) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why this change, I think this may be code to handle custom context menu (although we shouldn't probably use runtimetype check to infer this)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It ends up being the same before/after. The code to handle the context menu TextSelectionControls vs ContextMenuBuilder is in _showToolbar.

Copy link
Contributor

@chunhtai chunhtai Oct 13, 2025

Choose a reason for hiding this comment

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

oh I see, sounds good then. Can you add a todo in the runtitmeType check in _showToolbar to refactor that?

Copy link
Member

@loic-sharma loic-sharma left a comment

Choose a reason for hiding this comment

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

LGTM!

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

_selectionOverlay != null &&
(_selectionOverlay!.isDraggingStartHandle || _selectionOverlay!.isDraggingEndHandle);
if (widget.selectionControls is! TextSelectionHandleControls) {
if (!draggingHandles) {
Copy link
Contributor

@chunhtai chunhtai Oct 13, 2025

Choose a reason for hiding this comment

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

oh I see, sounds good then. Can you add a todo in the runtitmeType check in _showToolbar to refactor that?

Copy link
Contributor

@justinmc justinmc left a comment

Choose a reason for hiding this comment

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

LGTM 👍

Comment on lines +411 to +412
/// Whether the native browser context menu is enabled.
bool get _webContextMenuEnabled => kIsWeb && BrowserContextMenu.enabled;
Copy link
Contributor

Choose a reason for hiding this comment

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

Ah same strategy used in EditableText. More evidence that having two separate implementations of text selection leads to bugs.

@Renzo-Olivares Renzo-Olivares added the autosubmit Merge PR when tree becomes green via auto submit App label Oct 14, 2025
@auto-submit auto-submit bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Oct 14, 2025
@auto-submit
Copy link
Contributor

auto-submit bot commented Oct 14, 2025

autosubmit label was removed for flutter/flutter/176855, because - The status or check suite Mac_arm64 build_tests_3_4 has failed. Please fix the issues identified (or deflake) before re-applying this label.

  • The status or check suite Mac_arm64 build_tests_2_4 has failed. Please fix the issues identified (or deflake) before re-applying this label.

@Renzo-Olivares Renzo-Olivares force-pushed the sr-double-context-menu-fix branch 3 times, most recently from 0187953 to e819be3 Compare October 15, 2025 19:14
@Renzo-Olivares Renzo-Olivares force-pushed the sr-double-context-menu-fix branch from e819be3 to 941376a Compare October 16, 2025 04:33
@Renzo-Olivares Renzo-Olivares added the autosubmit Merge PR when tree becomes green via auto submit App label Oct 16, 2025
@auto-submit auto-submit bot added this pull request to the merge queue Oct 16, 2025
Merged via the queue into flutter:master with commit 666634b Oct 16, 2025
78 checks passed
@flutter-dashboard flutter-dashboard bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Oct 16, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Oct 16, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Oct 16, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Oct 16, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Oct 16, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Oct 16, 2025
auto-submit bot pushed a commit to flutter/packages that referenced this pull request Oct 16, 2025
…10244)

Manual roll requested by [email protected]

flutter/flutter@7cd821c...a873a27

2025-10-16 [email protected] [tool] makes listing a shader also as an asset a build failure (flutter/flutter#176866)
2025-10-16 [email protected] Roll Packages from d062181 to 835dccb (7 revisions) (flutter/flutter#177100)
2025-10-16 [email protected] Handle the new location of Perfetto in create_updated_flutter_deps.py (flutter/flutter#177099)
2025-10-16 [email protected] Implement dialog windows for the win32 platform (flutter/flutter#176309)
2025-10-16 [email protected] `SelectableRegion` should not show flutter rendered context menu when web context menu is enabled (flutter/flutter#176855)
2025-10-16 [email protected] Manual roll Skia to 2d9df7c70b6f (flutter/flutter#177074)
2025-10-16 [email protected] feat: add `OptionsViewOpenDirection.mostSpace` to `RawAutocomplete` (flutter/flutter#172997)
2025-10-16 [email protected] [Android] Refactor `ImageReaderSurfaceProducer` restoration after app resumes (flutter/flutter#175937)
2025-10-15 [email protected] Refactor: migrate fade upwards page transition builder to widgets (flutter/flutter#175560)
2025-10-15 [email protected] Marks Windows windowing_test to be unflaky (flutter/flutter#176701)
2025-10-15 [email protected] fix: 🐛 Add equality and hashCode implementations to ScrollAwareImageProvider (flutter/flutter#175038)
2025-10-15 [email protected] Updates `sliver_tree.1.dart‎` to use `MediaQuery.widthOf(context)`  (flutter/flutter#176888)
2025-10-15 [email protected] [web] Fix focus issues in newer versions of Chrome (flutter/flutter#176938)
2025-10-15 [email protected] [Android 16] Update `android_engine_vulkan_tests` to Test Against SDK 36 Emulator (flutter/flutter#176985)
2025-10-15 [email protected] Fix key events interception by RadioGroup when no Radio is focused. (flutter/flutter#176335)
2025-10-15 [email protected] Update cherry-pick instructions to include instructions for pre-release CPs (flutter/flutter#177020)
2025-10-15 [email protected] Manual roll Skia to c501c727a007 (flutter/flutter#177015)
2025-10-15 [email protected] Update examples to latest Linux runner style (flutter/flutter#177033)
2025-10-15 [email protected] [material/menu_anchor.dart] Create internal menu controller if external controller is changed to null. (flutter/flutter#176375)
2025-10-15 98614782+auto-submit[bot]@users.noreply.github.com Reverts "Fix - TalkBack does not announce list information (#174374)" (flutter/flutter#177062)
2025-10-14 [email protected] Implement Regular Windows for Linux (flutter/flutter#176187)
2025-10-14 [email protected] Fix - TalkBack does not announce list information (flutter/flutter#174374)

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 [email protected],[email protected] 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
reidbaker pushed a commit to AbdeMohlbi/flutter that referenced this pull request Dec 10, 2025
… web context menu is enabled (flutter#176855)

This change fixes an issue where the flutter rendered menu would show up
when ending a drag on a selection handle, even when the web context menu
was enabled. This led to issues where both context menus would show up
leading to a unfavorable experience.

Fixes flutter#175114

## Pre-launch Checklist

- [x] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [x] I read the [Tree Hygiene] wiki page, which explains my
responsibilities.
- [x] I read and followed the [Flutter Style Guide], including [Features
we expect every widget to implement].
- [x] I signed the [CLA].
- [x] I listed at least one issue that this PR fixes in the description
above.
- [x] I updated/added relevant documentation (doc comments with `///`).
- [x] I added new tests to check the change I am making, or this PR is
[test-exempt].
- [x] I followed the [breaking change policy] and added [Data Driven
Fixes] where supported.
- [x] All existing and new tests are passing.

---------

Co-authored-by: Renzo Olivares <[email protected]>
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.

[PWA] Duplicate “Copy” action shown when SelectionArea wraps — double copy menu

4 participants