Skip to content

Text input: a late echo of an earlier keystroke overwrites newer text (characters vanish while typing) #95

Description

@sandermj

Package: nativephp/mobile-ui 0.4.0, reproduces on current main
Platforms: iOS and Android, <text-input> bound with native:model or @change

A PR follows this issue.

Steps to reproduce

  1. Bind a text input to a property that the server round-trips, with a debounce, against a server a few hundred milliseconds away.
  2. Type a word quickly.

Expected: the field shows what was typed.

Actual: characters typed after an earlier keystroke disappear when that keystroke's round trip lands, then come back when the later one lands. On a search field this looks like the input fighting the user.

Cause

The echo-prevention in the text-input renderers keeps only the last value sent to PHP. With several commits in flight, PHP republishes an earlier keystroke's value; it differs from lastSentValue, so the "is this our own echo?" check passes and the field is set to the stale value.

Proposed fix

While the field is focused the user owns the text: server pushes are dropped for the focused field. iOS keeps the keep-focus-on-submit exception, where an empty server value clears the field. Unfocused fields keep accepting server values, so programmatic updates still land.

On Android the renderer tracks focus through the interaction source and returns early from the server-value LaunchedEffect while focused; on iOS the same check guards isFocused.

Patched for the outlined variant both platforms share; the bare and filled variants follow the same pattern and could take the same change.

Files involved

resources/ios/NativeUITextInputCore.swift, resources/android/OutlinedTextInputRenderer.kt.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions