File tree 1 file changed +17
-1
lines changed
src/client/packages/idom-client-react/src
1 file changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -81,7 +81,7 @@ function UserInputElement({ model }) {
81
81
// order to allow all changes committed by the user to be recorded in the order they
82
82
// occur. If we don't the user may commit multiple changes before we render next
83
83
// causing the content of prior changes to be overwritten by subsequent changes.
84
- const value = props . value ;
84
+ let value = props . value ;
85
85
delete props . value ;
86
86
87
87
// Instead of controlling the value, we set it in an effect.
@@ -91,6 +91,22 @@ function UserInputElement({ model }) {
91
91
}
92
92
} , [ ref . current , value ] ) ;
93
93
94
+ // Track a buffer of observed values in order to avoid flicker
95
+ const observedValues = React . useState ( [ ] ) [ 0 ] ;
96
+ if ( observedValues ) {
97
+ if ( value === observedValues [ 0 ] ) {
98
+ observedValues . shift ( ) ;
99
+ value = observedValues [ observedValues . length - 1 ] ;
100
+ } else {
101
+ observedValues . length = 0 ;
102
+ }
103
+ }
104
+
105
+ const givenOnChange = props . onChange ;
106
+ props . onChange = ( event ) => {
107
+ observedValues . push ( event . target . value ) ;
108
+ } ;
109
+
94
110
// Use createElement here to avoid warning about variable numbers of children not
95
111
// having keys. Warning about this must now be the responsibility of the server
96
112
// providing the models instead of the client rendering them.
You can’t perform that action at this time.
0 commit comments