carbon-react 101.0.4 → 101.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -344,7 +344,7 @@ const MultiSelect = /*#__PURE__*/_react.default.forwardRef(({
|
|
|
344
344
|
} = optionData;
|
|
345
345
|
|
|
346
346
|
if (selectionType === "navigationKey") {
|
|
347
|
-
setHighlightedValue(
|
|
347
|
+
setHighlightedValue(newValue);
|
|
348
348
|
return;
|
|
349
349
|
}
|
|
350
350
|
|
|
@@ -353,26 +353,23 @@ const MultiSelect = /*#__PURE__*/_react.default.forwardRef(({
|
|
|
353
353
|
}
|
|
354
354
|
|
|
355
355
|
setTextValue("");
|
|
356
|
+
const isAlreadySelected = selectedValue.findIndex(val => (0, _isExpectedValue.default)(val, newValue)) !== -1;
|
|
357
|
+
|
|
358
|
+
if (!isAlreadySelected && isControlled.current && onChange) {
|
|
359
|
+
onChange(createCustomEvent([...selectedValue, newValue]));
|
|
360
|
+
}
|
|
361
|
+
|
|
356
362
|
setSelectedValue(previousValue => {
|
|
357
363
|
textboxRef.focus();
|
|
358
364
|
isMouseDownReported.current = false;
|
|
359
|
-
const isAlreadySelected = previousValue.findIndex(val => (0, _isExpectedValue.default)(val, newValue)) !== -1;
|
|
360
365
|
|
|
361
366
|
if (isAlreadySelected) {
|
|
362
367
|
return previousValue;
|
|
363
368
|
}
|
|
364
369
|
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
if (isControlled.current && onChange) {
|
|
368
|
-
onChange(createCustomEvent(valueList));
|
|
369
|
-
return previousValue;
|
|
370
|
-
}
|
|
371
|
-
|
|
372
|
-
return valueList;
|
|
370
|
+
return [...previousValue, newValue];
|
|
373
371
|
});
|
|
374
|
-
},
|
|
375
|
-
[createCustomEvent, onChange, textboxRef]);
|
|
372
|
+
}, [createCustomEvent, onChange, textboxRef, selectedValue]);
|
|
376
373
|
|
|
377
374
|
function onSelectListClose() {
|
|
378
375
|
setOpenState(false);
|