-
Notifications
You must be signed in to change notification settings - Fork 254
Description
userEvent.type()
on an element with contenteditable
does not honor the cursor position / selection.
I've set up a code example to demonstrate the problem here:
https://codesandbox.io/s/usereventtype-on-contenteditable-obxib?file=/src/app.test.js
The input field with the content foo
has an EventListener that just copies InputEvents event.target.textContent
on another div
.
When you click one of the buttons and start typing bar
, you can see your input being inserted as expected.
Trying to emulate the behavior per userEvent.type
fails.
When the cursor is in front of foo
, it sets textContent
to foobar
instead of barfoo
.
When the cursor is behind foo
, it sets textContent
to fbaroo
instead if foobar
.
When the content is selected, it sets textContent
to baroo
instead of bar
.