File tree Expand file tree Collapse file tree 1 file changed +8
-3
lines changed Expand file tree Collapse file tree 1 file changed +8
-3
lines changed Original file line number Diff line number Diff line change @@ -40,11 +40,16 @@ async function type(
40
40
// The reason we have to do this at all is because it actually *is*
41
41
// programmatically changed by await fireEvent.input, so we have to simulate the
42
42
// browser's default behavior
43
+ const el = currentElement ( )
44
+ const { selectionStart, selectionEnd} = el
43
45
if (
44
- currentElement ( ) . selectionStart !== null &&
45
- currentValue ( ) === newValue
46
+ selectionStart !== null &&
47
+ currentValue ( ) === newValue &&
48
+ el . setSelectionRange &&
49
+ ( selectionStart !== newSelectionStart ||
50
+ selectionEnd !== newSelectionStart )
46
51
) {
47
- currentElement ( ) . setSelectionRange ?. ( newSelectionStart , newSelectionStart )
52
+ el . setSelectionRange ( newSelectionStart , newSelectionStart )
48
53
}
49
54
}
50
55
You can’t perform that action at this time.
0 commit comments