Skip to content

TextField inserts new characters at the start when initialized with existing text #50

@mikenye

Description

@mikenye

When a TextField is bound to a string that already contains text, typing can insert new characters at the start of the string instead of at the end where the caret appears to be.

This seems to happen when the same TextField widget is reused across editing sessions or window reopenings. The visible text is correct, but the internal insertion point/selection can remain stale, so the next typed character is inserted at byte 0 instead of after the existing text.

Expected behavior

If a TextField is opened with an existing value like "hello", focusing the field and typing "x" should produce "hellox".

Actual behavior

Focusing the field and typing "x" can produce "xhello".

Screen.Recording.2026-04-10.at.9.41.03.am.mov

How to reproduce

  1. Create a TextField bound to a string that already contains text.
  2. Render the UI window.
  3. Focus the field.
  4. Type a character.
  5. In my case this shows up reliably when the same UI/workspace is reused and the field is reopened with preloaded text.

Notes

As far as I can tell, this does not appear to be misuse of the API. It looks like the cached text input state is being reused without resetting the selection/caret position from the current bound string on focus.

A similar problem can also happen after programmatically replacing a field’s value: the visible text updates, but the next typed character can still insert at the start if the internal selection is left at 0,0.

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