question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

`type` regression if textarea has no value before typing

See original GitHub issue

Relevant code or config

test(" empty textarea", async () => {
  render(<textarea data-testid="textbox" />);

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

What you did:

Updated from 11.2.1 to 11.4.2

What happened:

library code types incorrectly if the textarea has no value when it start typing

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

Problem description:

It seems like the “type” event returns to the beginning of the line after it has typed the first letter, after that it returns to normal resulting in the first letter always being at the end of the word/sentence

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:14 (7 by maintainers)

github_iconTop GitHub Comments

2reactions
marcosvega91commented, Jun 29, 2020

The problem here is that before typing selectionStart and selectionEnd are undefined. I think that can be a problem of jsdom instead.

1reaction
ph-fritschecommented, Feb 16, 2021

@dave-cabbage The reproduction example of this issue works as expected with up-to-date dependencies: https://codesandbox.io/s/user-event-type-to-add-text-issue-forked-dezvq?file=/src/__tests__/App.test.js

Are you by chance using an old version of jsdom?

If your problem does not resolve by updating the dependencies on your project, please file a new issue with a reproduction example like above. 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

How do I preserve line breaks when getting text from a textarea?
The easiest solution is to simply style the element you're inserting the text into with the following CSS property: white-space: pre-wrap;.
Read more >
The Textarea element - HTML: HyperText Markup Language
This attribute specifies that the user must fill in a value before submitting a form. rows. The number of visible text lines for...
Read more >
HTML textarea tag - W3Schools
The <textarea> tag defines a multi-line text input control. The <textarea> element is often used in a form, to collect user inputs like...
Read more >
Gradio Docs
Browse Gradio Documentation and Examples.
Read more >
the text disappears when your typing on input or textarea with ...
Issue 152715: the text disappears when your typing on input or textarea with "text-transform: uppercase" style and you changes the value ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found