Skip to content

Touch-drag text selection is interrupted mid-gesture (rc14) #747

Description

@dheerm-titan

Version

com.mohamedrejeb.richeditor:richeditor-compose 1.0.0-rc14 (Android)

Describe the bug

Selecting text by touch-drag (press, then drag to extend the selection — without first long-pressing) is interrupted mid-gesture: the selection stops extending while the finger is still down, and you have to lift and start again. It's worst crossing a word boundary or line break.

Long-press-then-drag (dragging the selection handles after a long-press) is smooth — only the direct press-drag-to-select path is affected.

Root cause (from reading the rc14 source)

On every selection change during a drag, RichTextState.onTextFieldValueChangeupdateTextFieldValue takes the maskAffected branch (the drag selection is non-collapsed) and calls updateAnnotatedString(...), which rebuilds annotatedString and reassigns textFieldValue to a new instance (newTextFieldValue.copy(...)) on every tick — this is the selection-highlight background mask (code comments reference #635).

Hypothesis for the interruption: the underlying BasicTextField receives an externally-updated value on every drag frame, which resets its in-progress selection gesture.

This also seems consistent with the long-press difference — the multi-paragraph workaround (adjustSelection, gated on lastPressPosition, which is cleared ~300 ms after the press) is active only in the first ~300 ms of a press, the window a quick press-drag falls in.

To Reproduce

  1. Show a RichTextEditor/OutlinedRichTextEditor with a few lines of text (multi-paragraph makes it worse).
  2. On a touch device, press on a word and drag to extend the selection — do not long-press first.
  3. The selection stops extending partway through while the finger keeps moving; you must release and retry.

Expected behavior

Press-drag selection extends continuously with the finger, like a plain Compose BasicTextField.

Environment

  • richeditor-compose: 1.0.0-rc14
  • Jetpack Compose BOM: 2026.03.01
  • Platform: Android (touch)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions