Open
Description
Problem description
When using .type()
I've been finding a common pattern that emerges is variations on the following
await userEvent.type(titleInput, 'Edited title', {
initialSelectionStart: 0,
initialSelectionEnd: titleInput.value.length,
});
To represent selecting the whole content and then overwriting it when typing
There was some related discussion in #755 (comment)
Suggested solution
Adding a new property like selectAll
would be convenient, but probably opens up some awkward interactions if initialSelectionStart
or initialSelectionEnd
are also supplied.
From poking around in the code it looks like if I simply set a large value for initialSelectionEnd
then it'll get clamped to the length of the input - which is basically what I want (although it's still quite verbose in a test). Perhaps the answer would be document the pattern of using a large number or Infinity
as the selection end?
Additional context
No response