@@ -262,7 +262,11 @@ class ChipInput extends React.Component {
262262 if ( this . state . focusedChip == null && event . keyCode === 8 ) {
263263 this . setState ( { focusedChip : chips [ chips . length - 1 ] } )
264264 } else if ( this . state . focusedChip ) {
265- const index = chips . indexOf ( this . state . focusedChip )
265+ const index = chips . findIndex ( ( chip ) => {
266+ return this . props . dataSourceConfig
267+ ? this . state . focusedChip [ this . props . dataSourceConfig . value ] === chip [ this . props . dataSourceConfig . value ]
268+ : this . state . focusedChip === chip
269+ } )
266270 const value = this . props . dataSourceConfig ? this . state . focusedChip [ this . props . dataSourceConfig . value ] : this . state . focusedChip
267271 this . handleDeleteChip ( value , index )
268272 if ( event . keyCode === 8 && index > 0 ) {
@@ -274,13 +278,21 @@ class ChipInput extends React.Component {
274278 }
275279 } else if ( event . keyCode === 37 ) {
276280 const chips = this . props . value || this . state . chips
277- const index = chips . indexOf ( this . state . focusedChip )
281+ const index = chips . findIndex ( ( chip ) => {
282+ return this . props . dataSourceConfig
283+ ? this . state . focusedChip [ this . props . dataSourceConfig . value ] === chip [ this . props . dataSourceConfig . value ]
284+ : this . state . focusedChip === chip
285+ } )
278286 if ( index > 0 ) {
279287 this . setState ( { focusedChip : chips [ index - 1 ] } )
280288 }
281289 } else if ( event . keyCode === 39 ) {
282290 const chips = this . props . value || this . state . chips
283- const index = chips . indexOf ( this . state . focusedChip )
291+ const index = chips . findIndex ( ( chip ) => {
292+ return this . props . dataSourceConfig
293+ ? this . state . focusedChip [ this . props . dataSourceConfig . value ] === chip [ this . props . dataSourceConfig . value ]
294+ : this . state . focusedChip === chip
295+ } )
284296 if ( index >= 0 && index < chips . length - 1 ) {
285297 this . setState ( { focusedChip : chips [ index + 1 ] } )
286298 } else {
0 commit comments