This repository was archived by the owner on Dec 23, 2022. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +7
-6
lines changed Expand file tree Collapse file tree 2 files changed +7
-6
lines changed Original file line number Diff line number Diff line change @@ -152,7 +152,6 @@ class ChipInput extends React.Component {
152152 if ( newChipKeyCodes . indexOf ( event . keyCode ) >= 0 && event . target . value ) {
153153 event . preventDefault ( )
154154 this . handleAddChip ( event . target . value )
155- this . autoComplete . setState ( { searchText : '' } )
156155 this . autoComplete . forceUpdate ( )
157156 } else {
158157 handleKeyDown ( event )
@@ -165,10 +164,6 @@ class ChipInput extends React.Component {
165164 const index = parseInt ( child . key , 10 )
166165 const chosenRequest = dataSource [ index ]
167166 this . handleAddChip ( chosenRequest )
168-
169- this . autoComplete . setState ( {
170- searchText : ''
171- } )
172167 this . autoComplete . forceUpdate ( )
173168 this . autoComplete . close ( )
174169
@@ -328,7 +323,7 @@ class ChipInput extends React.Component {
328323
329324 handleAddChip ( chip ) {
330325 if ( this . props . onBeforeRequestAdd && ! this . props . onBeforeRequestAdd ( chip ) ) {
331- return this . setState ( { preventChipCreation : true , inputValue : this . autoComplete . state . searchText } )
326+ return this . setState ( { preventChipCreation : true } )
332327 }
333328 this . autoComplete . setState ( { searchText : '' } )
334329 const chips = this . props . value || this . state . chips
Original file line number Diff line number Diff line change @@ -232,6 +232,12 @@ storiesOf('ChipInput', module)
232232 allowDuplicates
233233 />
234234 )
235+ . add ( 'with onBeforeRequestAdd returning false' , ( ) =>
236+ < ChipInput
237+ defaultValue = { [ 'foo' , 'bar' , 'foo' , 'bar' ] }
238+ onBeforeRequestAdd = { ( ) => false }
239+ />
240+ )
235241 . add ( 'tabbing between fields' , ( ) =>
236242 < form >
237243 < ChipInput
You can’t perform that action at this time.
0 commit comments