Skip to content

Rework userEvent.type #521

@ph-fritsche

Description

@ph-fritsche

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.

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    accuracyImproves the accuracy of how behavior is simulatedenhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions