-
Notifications
You must be signed in to change notification settings - Fork 254
Description
We've got multiple open issues regarding the implementation of userEvent.type
.
And while a few people offered help on this, I've got the impression we're a bit lost regarding what the code should do and look like in general as well as how and where each smaller problem should be addressed.
I propose we collect those issues, discuss what we want to achieve and refactor and comment the code so that we get more confidence working on this.
- Typing on contenteditable userEvent.type on contenteditable #442
- Referencing characters by
keyEvent.code
userEvent.type: wrong keyCode for dot character? #456 - Handling activeElement changing to another element show warning when using
userevent.type
andblur()
#460 / Fix #460 #487 - Preserving input over value sanitization userEvent.type not entering a space into inputs with type email #479
- Typing on non-input elements The type event doesn't work on elements without a value property #481 , Firing {delete} or {backspace} in situations that have no input text string #506
- Selecting on non-text input elements Problems with custom input types #501, Incorrect event.target.selectionStart value when using left arrow and backspace keys #515
- Default behavior on clickable elements onClick event fired twice by typing "{enter}" or "{space}" on button element #554
- Prevent default behavior and missing events on navigation keys Arrowleft handler does not respect preventDefault resulting in incorrect selectionStart #578
Should I have overlooked something, please mention it and I'll add it to the list.
What do people expect userEvent.type
to do? What should it do?
While userEvent.click
is very clear and intuitive to use as userEvent click this element!
,
I guess userEvent.type
started the same way userEvent trigger the key events to add to the value of this element!
,
but I think most people expect it to be more userEvent press those buttons on the keyboard!
.
I think it should resolve around document.getSelection()
and userEvent.type(null, "a{del}{shift}b{tab}c{/shift}[Semicolon]d{selectall}")
should be a valid expression to test handling of hot keys and similar.
One problem that comes to my mind is how to handle the keypress events as they are triggered multiple times as long as the button is pressed. Maybe a configurable random timeout between key events? So that even an expression for Press [A] and then press [B] before releasing [A]. Then release [B].
would make sense.