testing-library / testing-library/user-event

Wrong `Selection` when `<input/>` inside contenteditable is focused

Open
#1,248 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
TypeScript
Stars
2.3k
Forks
258
PR merge metrics
No merged PRs in 30d

Description

Reproduction example

https://codesandbox.io/p/sandbox/nostalgic-sutherland-w2n2w8

Prerequisites
  1. Render <div contenteditable="true"><input/></div>
  2. Focus the HTMLInputElement
Expected behavior

The selection has one collapsed range at the position of the input element.

Actual behavior

The selection has no range.

User-event version

14.5.2

Environment

Testing Library framework:

JS framework:

Test environment:

DOM implementation:

Additional context

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the linked CodeSandbox reproduction and trace how focusing an HTMLInputElement inside a contenteditable element affects the Selection. Done means the selection contains one collapsed range at the input position instead of no range, under the reported Testing Library, React, Jest, and jsdom versions.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, react, typescript
Domain
frontend, testing
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.