File tree Expand file tree Collapse file tree 2 files changed +22
-1
lines changed Expand file tree Collapse file tree 2 files changed +22
-1
lines changed Original file line number Diff line number Diff line change @@ -450,7 +450,7 @@ const Select = React.forwardRef(
450
450
? {
451
451
label : option ?. [ mergedFieldNames . label ] ,
452
452
value : val ,
453
- key : option . key ?? val ,
453
+ key : option ? .key ?? val ,
454
454
}
455
455
: val ,
456
456
injectPropsWithOption ( option ) ,
Original file line number Diff line number Diff line change @@ -475,6 +475,27 @@ describe('Select.Multiple', () => {
475
475
expect ( wrapper . exists ( '.rc-select-selection-item-remove' ) ) . toBeFalsy ( ) ;
476
476
} ) ;
477
477
478
+ it ( 'do not crash if value not in options when removing option' , ( ) => {
479
+ const wrapper = mount (
480
+ < Select
481
+ defaultValue = { [
482
+ {
483
+ label : 'value not in options' ,
484
+ value : 'value-not-in-options' ,
485
+ } ,
486
+ ] }
487
+ mode = "multiple"
488
+ labelInValue
489
+ >
490
+ < Option value = { 1 } > 1</ Option >
491
+ < Option value = { 2 } > 2</ Option >
492
+ </ Select > ,
493
+ ) ;
494
+ expect ( findSelection ( wrapper , 0 ) . text ( ) ) . toEqual ( 'value not in options' ) ;
495
+ removeSelection ( wrapper , 0 ) ;
496
+ expect ( wrapper . find ( 'Selector' ) . props ( ) . values . length ) . toEqual ( 0 ) ;
497
+ } ) ;
498
+
478
499
describe ( 'optionLabelProp' , ( ) => {
479
500
it ( 'basic' , ( ) => {
480
501
const wrapper = mount (
You can’t perform that action at this time.
0 commit comments