File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -131,26 +131,28 @@ export default class Async extends Component {
131131 isLoading : true
132132 } ) ;
133133 }
134-
135- return inputValue ;
136134 }
137135
138136 _onInputChange ( inputValue ) {
139137 const { ignoreAccents, ignoreCase, onInputChange } = this . props ;
138+ let transformedInputValue = inputValue ;
140139
141140 if ( ignoreAccents ) {
142- inputValue = stripDiacritics ( inputValue ) ;
141+ transformedInputValue = stripDiacritics ( transformedInputValue ) ;
143142 }
144143
145144 if ( ignoreCase ) {
146- inputValue = inputValue . toLowerCase ( ) ;
145+ transformedInputValue = transformedInputValue . toLowerCase ( ) ;
147146 }
148147
149148 if ( onInputChange ) {
150- onInputChange ( inputValue ) ;
149+ onInputChange ( transformedInputValue ) ;
151150 }
152151
153- return this . loadOptions ( inputValue ) ;
152+ this . loadOptions ( transformedInputValue ) ;
153+
154+ // Return the original input value to avoid modifying the user's view of the input while typing.
155+ return inputValue ;
154156 }
155157
156158 inputValue ( ) {
Original file line number Diff line number Diff line change @@ -319,6 +319,15 @@ describe('Async', () => {
319319 typeSearchText ( 'WÄRE' ) ;
320320 expect ( loadOptions , 'was called with' , 'WÄRE' ) ;
321321 } ) ;
322+
323+ it ( 'does not mutate the user input' , ( ) => {
324+ createControl ( {
325+ ignoreAccents : false ,
326+ ignoreCase : true
327+ } ) ;
328+ typeSearchText ( 'A' ) ;
329+ expect ( asyncNode . textContent , 'to begin with' , 'A' ) ;
330+ } ) ;
322331 } ) ;
323332
324333 describe ( 'with ignore case and ignore accents' , ( ) => {
You can’t perform that action at this time.
0 commit comments