testing-library / testing-library/user-event
Typing Backspace multiple times results in wrong cursor position
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 2.3k
- Forks
- 258
- PR merge metrics
- No merged PRs in 30d
Description
Reproduction example
https://codesandbox.io/s/elastic-surf-6qegdh?file=/src/App.test.js
Prerequisites
- Render
<input type="text" /> - Type
abc - Press
{ArrowLeft}{Backspace}{Backspace}
Expected behavior
input element value should be 'c' and cursor position should be 0
Actual behavior
The input element value is "a" and the cursor position is 1
User-event version
14.4.3
Environment
Testing Library framework:
JS framework:
Test environment:
DOM implementation:
Additional context
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the linked CodeSandbox reproduction in /src/App.test.js and reproduce the ArrowLeft/Backspace sequence against the stated user-event, React, Jest, and jsdom versions. Trace the input value and cursor position after each key event; done means the value is 'c' and the cursor position is 0.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, react, typescript
- Domain
- frontend, testing
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100