Skip to content

[bug]: Cursor jumps to the end when editing in the middle #1111

@MdTehseenKhan

Description

@MdTehseenKhan

Describe the bug

In ShortTextCell and UrlCell, when editing a cell and typing in the middle of the text, the caret jumps to the end after each keystroke. The useEffect that focuses the cell and sets the selection has value in its dependency array, and onInput calls setValue(currentValue) on every change. So each keystroke updates value, re-runs the effect, and the effect’s range.collapse(false) moves the selection to the end of the content.

How to reproduce

  1. Go to Data Grid
  2. Enter edit mode on a cell that already has text (e.g. "hello world") in any of the columns: Name, Email, or Website
  3. Place cursor in the middle of the text (e.g. between "hello" and " world")
  4. Type one or more characters.
  5. Expected: New characters are inserted at the cursor and the cursor stays in place.
  6. Actual: The cursor jumps to the end of the text after each keystroke.

Link to reproduction

https://tablecn.com/data-grid

Additional information

TableCN.mp4

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