File tree 1 file changed +8
-1
lines changed
1 file changed +8
-1
lines changed Original file line number Diff line number Diff line change @@ -61,12 +61,19 @@ async function typeImpl(
61
61
// The reason we have to do this at all is because it actually *is*
62
62
// programmatically changed by fireEvent.input, so we have to simulate the
63
63
// browser's default behavior
64
- if ( currentValue ( ) === newValue ) {
64
+ const value = currentValue ( )
65
+
66
+ if ( value === newValue ) {
65
67
setSelectionRangeIfNecessary (
66
68
currentElement ( ) ,
67
69
newSelectionStart ,
68
70
newSelectionStart ,
69
71
)
72
+ } else {
73
+ // If the currentValue is different than the expected newValue and we *can*
74
+ // change the selection range, than we should set it to the length of the
75
+ // currentValue to ensure that the browser behavior is mimicked.
76
+ setSelectionRangeIfNecessary ( currentElement ( ) , value . length , value . length )
70
77
}
71
78
}
72
79
You can’t perform that action at this time.
0 commit comments