Skip to content

Fix/prevent cursor from jumping to end when editing component text - #876

Closed
ivanruizcode wants to merge 1 commit into
Lemoncode:devfrom
ivanruizcode:fix/input-cursor-position
Closed

Fix/prevent cursor from jumping to end when editing component text#876
ivanruizcode wants to merge 1 commit into
Lemoncode:devfrom
ivanruizcode:fix/input-cursor-position

Conversation

@ivanruizcode

Copy link
Copy Markdown
Collaborator

Inline-edit inputs (shown when double-clicking a canvas component to change its text) rendered the cursor at the end of the field on every keystroke, making it impossible to move back and edit previous words. The inputs were controlled (value + onChange), but they're mounted through react-konva-utils' Html, which renders its children into a separate React root and re-renders them out-of-band on every update. Because that re-render happens outside the root that owns the input, React re-applied the DOM .value on each change and the browser reset the caret to the end.

The fix makes the and <textarea> uncontrolled (defaultValue instead of value) in html-edit.widget.tsx. This is safe because the submit logic already reads the final text directly from the input ref rather than from React state, so no functional behavior changes, the caret now simply stays where the user placed it. Affects all inline-editable components (inputs, textareas, headings, paragraphs, links, etc.) since they share this widget.

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.

1 participant