Skip to content

Text selection extends incorrectly upward during mouse drag on web/desktop #2697

@Sun-Deep

Description

@Sun-Deep

Have you checked for an existing issue?

Flutter Quill Version

11.5.0

Steps to Reproduce

  1. Open a QuillEditor with multiple paragraphs or bullet points on web or desktop platform
  2. Click and drag downward to select text (e.g., start at "Look" and drag to select "Look at pictures")
  3. Observe the selection during the drag operation

Expected results

Selection should smoothly follow the mouse position, selecting text from the click start point to the current mouse position.

Actual results

  • Selection erratically extends upward to content above the drag start point during the drag
  • The visual selection jumps around unpredictably during drag
  • Selection snaps to the correct position only when mouse button is released

Additional Context

After investigating the source code, the issue appears to be in RenderEditor.getPositionForOffset() or RenderEditor.extendSelection() which incorrectly calculates text positions during drag operations, particularly near line boundaries.

Key observations:

  • The bug occurs at the render/paint level before the controller is notified
  • Controller-based workarounds (intercepting selection changes) don't work because the visual glitch happens before any listener is called
  • The final selection on mouse release IS correct - only the visual feedback during drag is wrong

This may be related to:

Workaround Attempts (Failed)

  1. SelectionSmootherWrapper with controller listener - Controller not notified during drag
  2. RawGestureDetector to intercept gestures - QuillEditor's internal gesture detector wins arena
  3. Listener with position smoothing - Same issue, render happens before notification

None of these work because the visual issue occurs at the RenderEditor paint level.

Suggested Fix Location

The issue likely needs to be fixed in one of these locations:

  • lib/src/editor/editor.dartRenderEditor.extendSelection()
  • lib/src/editor/editor.dartRenderEditor.getPositionForOffset()
  • lib/src/editor/widgets/delegate.dartonDragSelectionUpdate()

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions