testing-library / testing-library/user-event

userEvent.paste is case-sensitive

Open
#1,179 1 comment 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/s/pensive-morning-5fttk8?file=/src/App.js

Prerequisites
  1. Render element
  2. add on paste listener with event.clipboardData?.getData('Text')
  3. call userEvent.paste('hello')
Expected behavior

event.clipboardData?.getData('Text') returned hello

Actual behavior

event.clipboardData?.getData('Text') returned undefined

User-event version

14.5.1

Environment

No response

Additional context

I noticed an issue with userEvent.paste in the following case.

Nevertheless, in the browser, such code works. After examining the Chromium source code, I confirmed this. Chrome intentionally converts the data type name to lowercase. It seems more appropriate to implement similar logic on the userEvent side.

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 by locating the userEvent.paste implementation and its existing tests, then reproduce the reported input and clipboard listener behavior from the issue. The change is done when clipboard data type lookup treats 'Text' like the browser does and the regression is covered by a passing test.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
testing
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.