-
Notifications
You must be signed in to change notification settings - Fork 29.7k
No SystemContextMenu when readOnly is true #171242
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
Conversation
| EditableTextState editableTextState, | ||
| ) { | ||
| if (defaultTargetPlatform == TargetPlatform.iOS && SystemContextMenu.isSupported(context)) { | ||
| if (defaultTargetPlatform == TargetPlatform.iOS && |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if we should share this logic somewhere, maybe under EditableTextState as supportsSystemContextMenu? Not required for this PR but just a thought I had since I see the same logic duplicated across multiple files.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good call. SystemContextMenu imports EditableText, so I made it a static method on SystemContextMenu.
| if (defaultTargetPlatform == TargetPlatform.iOS && SystemContextMenu.isSupported(context)) { | ||
| if (defaultTargetPlatform == TargetPlatform.iOS && | ||
| SystemContextMenu.isSupported(context) && | ||
| !editableTextState.widget.readOnly) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might be helpful to have a comment here on why the system context menu is not supported with readOnly set to true (here and in other files/ or a centralized place).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added on SystemContextMenu.isSupportedByField.
Could you please provide some details on what is blocking us from implementing native context menu without a text connection? I am not very familiar with native iOS development. It seems to me that having a native context menu in all cases would be even more important with the release of iOS 26, since IIUC it changes the appearance of the context menu, while Flutter's context menu still resembles the iOS 18 one. |
|
@hellohuanlin What would it take to be able to show the system context menu without an active UITextView? Originally we used it to determine which buttons to show, but now that can be specified by the user, so maybe it's easier to do now. |
The native edit menu is powered by an So to support the non-editable text (which doesn't have a backing |
|
Thanks @hellohuanlin, I created this issue to track: #171732 |
|
|
||
| expect(SystemContextMenu.isSupported(buildContext), isFalse); | ||
| }, | ||
| skip: kIsWeb, // [intended] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: add reason for skipping like // [intended] on web the browser handles the context menu. here and below.
| EditableTextState editableTextState, | ||
| ) { | ||
| if (defaultTargetPlatform == TargetPlatform.iOS && SystemContextMenu.isSupported(context)) { | ||
| if (defaultTargetPlatform == TargetPlatform.iOS && |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should be changed to SystemContextMenu.isSupportedByField(editableTextState) I think.
I think I had misread the previous analyzer failure as coming from the wrong file.
9401ef4 to
f9b467e
Compare
894bb27 to
bfb4912
Compare
My autoformatter does something different! Not sure what's up.
flutter/flutter@9c626d9...440713c 2025-07-18 [email protected] Add OS version support section to plugin docs (flutter/flutter#172316) 2025-07-18 [email protected] Roll Dart SDK from 7fcc5f48c335 to fe2232bd5b9f (2 revisions) (flutter/flutter#172339) 2025-07-18 [email protected] Refactor handling of frame waiting. (flutter/flutter#172277) 2025-07-18 [email protected] Roll pub packages (flutter/flutter#172332) 2025-07-17 [email protected] Refactor and forbid `base/exit.dart` outside of `lib/runner.dart` (flutter/flutter#171923) 2025-07-17 [email protected] Use UTC timezone for `stamp_command_test` to avoid local TZ flakes (flutter/flutter#172319) 2025-07-17 [email protected] [web] Add tests for unified platform view embedding behavior (flutter/flutter#172313) 2025-07-17 [email protected] Platform views shouldn't receive pointer events when not laid out (flutter/flutter#172043) 2025-07-17 [email protected] Fix Size.isEmpty description (flutter/flutter#172021) 2025-07-17 [email protected] feat: Add `maxCount` parameter to `Badge.count` constructor. (flutter/flutter#171054) 2025-07-17 [email protected] add `debugPaintTextLayoutBoxes` for debugging text layout (flutter/flutter#168876) 2025-07-17 [email protected] Roll Packages from 4a231ae to cb8fef6 (31 revisions) (flutter/flutter#172303) 2025-07-17 [email protected] Fix mutating Paint bug (flutter/flutter#171180) 2025-07-17 [email protected] No SystemContextMenu when readOnly is true (flutter/flutter#171242) 2025-07-17 [email protected] Add a getter to get the recorder used by painting context (flutter/flutter#170223) 2025-07-17 [email protected] [Impeller] Add missing SetPipeline call for the vertices uber pipeline in AtlasContents (flutter/flutter#172273) 2025-07-17 [email protected] Roll Dart SDK from 486f9c0663bc to 7fcc5f48c335 (1 revision) (flutter/flutter#172279) 2025-07-17 [email protected] Roll Skia from 3673a1f26a63 to 9587301e33bc (3 revisions) (flutter/flutter#172281) 2025-07-17 [email protected] Fix a race in FlutterEngineTest.CanLogToStdout (flutter/flutter#172025) 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
When readOnly is true, there is no TextInputConnection, so the SystemContextMenu can't be shown. Instead, this shows the Flutter-drawn context menu. This video shows the change. You can slightly tell that the system context menu is shown when readOnly is false and the Flutter-drawn context menu is shown when it is true. https://github.com/user-attachments/assets/91480fa4-cce6-4d63-ae11-df72a229da73 This is the same root cause as flutter#169238. Fixes flutter#170521
…r#9646) flutter/flutter@9c626d9...440713c 2025-07-18 [email protected] Add OS version support section to plugin docs (flutter/flutter#172316) 2025-07-18 [email protected] Roll Dart SDK from 7fcc5f48c335 to fe2232bd5b9f (2 revisions) (flutter/flutter#172339) 2025-07-18 [email protected] Refactor handling of frame waiting. (flutter/flutter#172277) 2025-07-18 [email protected] Roll pub packages (flutter/flutter#172332) 2025-07-17 [email protected] Refactor and forbid `base/exit.dart` outside of `lib/runner.dart` (flutter/flutter#171923) 2025-07-17 [email protected] Use UTC timezone for `stamp_command_test` to avoid local TZ flakes (flutter/flutter#172319) 2025-07-17 [email protected] [web] Add tests for unified platform view embedding behavior (flutter/flutter#172313) 2025-07-17 [email protected] Platform views shouldn't receive pointer events when not laid out (flutter/flutter#172043) 2025-07-17 [email protected] Fix Size.isEmpty description (flutter/flutter#172021) 2025-07-17 [email protected] feat: Add `maxCount` parameter to `Badge.count` constructor. (flutter/flutter#171054) 2025-07-17 [email protected] add `debugPaintTextLayoutBoxes` for debugging text layout (flutter/flutter#168876) 2025-07-17 [email protected] Roll Packages from 4a231ae to cb8fef6 (31 revisions) (flutter/flutter#172303) 2025-07-17 [email protected] Fix mutating Paint bug (flutter/flutter#171180) 2025-07-17 [email protected] No SystemContextMenu when readOnly is true (flutter/flutter#171242) 2025-07-17 [email protected] Add a getter to get the recorder used by painting context (flutter/flutter#170223) 2025-07-17 [email protected] [Impeller] Add missing SetPipeline call for the vertices uber pipeline in AtlasContents (flutter/flutter#172273) 2025-07-17 [email protected] Roll Dart SDK from 486f9c0663bc to 7fcc5f48c335 (1 revision) (flutter/flutter#172279) 2025-07-17 [email protected] Roll Skia from 3673a1f26a63 to 9587301e33bc (3 revisions) (flutter/flutter#172281) 2025-07-17 [email protected] Fix a race in FlutterEngineTest.CanLogToStdout (flutter/flutter#172025) 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
When readOnly is true, there is no TextInputConnection, so the SystemContextMenu can't be shown. Instead, this shows the Flutter-drawn context menu. This video shows the change. You can slightly tell that the system context menu is shown when readOnly is false and the Flutter-drawn context menu is shown when it is true. https://github.com/user-attachments/assets/91480fa4-cce6-4d63-ae11-df72a229da73 This is the same root cause as flutter#169238. Fixes flutter#170521
|
when would this land on stable? |
When readOnly is true, there is no TextInputConnection, so the SystemContextMenu can't be shown. Instead, this shows the Flutter-drawn context menu. This video shows the change. You can slightly tell that the system context menu is shown when readOnly is false and the Flutter-drawn context menu is shown when it is true. https://github.com/user-attachments/assets/91480fa4-cce6-4d63-ae11-df72a229da73 This is the same root cause as flutter#169238. Fixes flutter#170521
When readOnly is true, there is no TextInputConnection, so the SystemContextMenu can't be shown. Instead, this shows the Flutter-drawn context menu. This video shows the change. You can slightly tell that the system context menu is shown when readOnly is false and the Flutter-drawn context menu is shown when it is true. https://github.com/user-attachments/assets/91480fa4-cce6-4d63-ae11-df72a229da73 This is the same root cause as flutter#169238. Fixes flutter#170521
When readOnly is true, there is no TextInputConnection, so the SystemContextMenu can't be shown. Instead, this shows the Flutter-drawn context menu.
This video shows the change. You can slightly tell that the system context menu is shown when readOnly is false and the Flutter-drawn context menu is shown when it is true.
Screen.Recording.2025-06-26.at.2.31.43.PM.mov
This is the same root cause as #169238.
Fixes #170521