Skip to content

Fix selection handles that cannot be dragged on iOS - #595

Open
debagi4 wants to merge 1 commit into
fleather-editor:masterfrom
debagi4:fix/ios-selection-handles
Open

debagi4 wants to merge 1 commit into
fleather-editor:masterfrom
debagi4:fix/ios-selection-handles

Conversation

@debagi4

@debagi4 debagi4 commented Dec 5, 2026

Copy link
Copy Markdown

Fixes #576.

On iOS, the selection handles of a FleatherEditor could not be dragged: they disappeared as soon as you touched them. Inside a non-scrollable editor, dragging also stopped with an exception. We traced both causes on a real iPhone; TextField in the same app was not affected.

Causes

  1. Handles disappear when touched. With the system context menu (iOS 16+), iOS dismisses the menu as soon as a selection handle is touched. Fleather's SystemContextMenu.editor passes editorState.hideToolbar as onSystemHide, and its default hideHandles = true hides the whole selection overlay. The handle is removed from under the finger and the pan gesture is cancelled. Flutter's SystemContextMenu.editableText uses hideToolbar(false) here, which is why TextField works.
  2. Drag throws in a non-scrollable editor. With scrollable: false, the editor's scrollController is never attached. A handle drag calls bringIntoView, which reads scrollController.position and throws before the selection is updated. Now, when the controller has no clients, the caret is revealed through renderEditor.showOnScreen. This is the same thing _showCaretOnScreen does for a non-scrollable editor.

I'm not sure the GestureDetector from the issue's reproduction is what triggers this. Cause 1 happens whenever the system context menu is in use, with or without a GestureDetector.

Changes

  • system_context_menu.dart: onSystemHide: () => editorState.hideToolbar(false).
  • editor_selection_delegate_mixin.dart: bringIntoView no longer touches an unattached scroll controller.
  • Two tests in editor_test.dart. Both fail without these changes:
    • hiding the system context menu keeps the selection handles;
    • a selection handle can be dragged in a non-scrollable editor.

Testing

  • flutter test in packages/fleather: all tests pass. I ran them locally on Flutter 3.44.8.
  • flutter analyze is clean.
  • Tested on an iPhone in a release build of our app, which uses Fleather 1.27.0 with the same two changes. The selection handles now drag in a non-scrollable editor inside a ListView.

🤖 Generated with Claude Code

- Hiding the iOS system context menu no longer hides the selection
  handles. iOS dismisses the menu as soon as a handle is touched, and
  hideToolbar() with the default hideHandles = true removed the handle
  from under the finger. EditableText uses hideToolbar(false) here.
- bringIntoView no longer throws in a non-scrollable editor: its scroll
  controller is not attached, so the caret is revealed through
  RenderEditor.showOnScreen instead. The exception interrupted handle
  drags before the selection was updated.

Fixes fleather-editor#576

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@codecov

codecov Bot commented Dec 5, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 88.12%. Comparing base (9900cdd) to head (a4d6cca).

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #595      +/-   ##
==========================================
+ Coverage   88.10%   88.12%   +0.01%     
==========================================
  Files          63       63              
  Lines       10984    10990       +6     
==========================================
+ Hits         9678     9685       +7     
+ Misses       1306     1305       -1     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@debagi4

debagi4 commented Dec 5, 2026

Copy link
Copy Markdown
Author

@amantoux @Amir-P could you take a look when you have a moment? It fixes #576: selection handles on iOS disappear as soon as they are touched, because of the system context menu. It also fixes the exception that stops handle drags in a non-scrollable editor. Both have regression tests, and we checked the fix on a real iPhone. Thanks!

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Wrapping FleatherEditor in GestureDetector interferes with iOS selection handles

1 participant