Skip to content

type regression if input or textarea has text in it (11.0.1+) #321

@hudochenkov

Description

@hudochenkov

Relevant code or config

test("input: type uncontrolled", async () => {
  render(<input type="text" defaultValue="Hello," />);

  await userEvent.type(screen.getByRole("textbox"), "1234");
  expect(screen.getByRole("textbox")).toHaveValue("Hello,1234");
});

What you did:

Updated library from v10 to the latest version.

What happened:

Library types code incorrectly, if input or textarea already has text in it.

Reproduction repository:

https://codesandbox.io/s/user-event-type-to-add-text-issue-9hkpu?file=/src/__tests__/App.test.js

Problem description:

When typing in a input or textarea, when there is text already, typing happens in a weird manner.

In repository above, we have textarea with text Hello, in it. Then we type 1234. I checked all versions from 11.0.0 till the latest one and this behavior changed many times. Unfortunately, every time it was broken:

Version Controlled Uncontrolled
11.0.0 Hello,1234 Hello,1234
11.0.1 Hello,4 Hello,1234
11.1.0 234llo, 234llo,
11.2.0 234llo, 234llo,
11.2.1 1Hello,234 1Hello,234

As we can see version 11.0.1 introduced issues, and then they evolved.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions