Skip to content

Commit 633929b

Browse files
Fix value prop to keep SelectInput's input as controlled (#8048)
1 parent 31eb3ab commit 633929b

1 file changed

Lines changed: 9 additions & 11 deletions

File tree

components/lib/multiselect/MultiSelect.js

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -887,21 +887,19 @@ export const MultiSelect = React.memo(
887887
};
888888

889889
const getLabel = () => {
890-
let label;
891-
892-
if (!empty && !props.fixedPlaceholder) {
893-
if (ObjectUtils.isNotEmpty(props.maxSelectedLabels) && props.value?.length > props.maxSelectedLabels) {
894-
return getSelectedItemsLabel();
895-
}
890+
if (empty || props.fixedPlaceholder) {
891+
return '';
892+
}
896893

897-
if (ObjectUtils.isArray(props.value)) {
898-
return props.value.reduce((acc, value, index) => acc + (index !== 0 ? ', ' : '') + getLabelByValue(value), '');
899-
}
894+
if (ObjectUtils.isNotEmpty(props.maxSelectedLabels) && props.value?.length > props.maxSelectedLabels) {
895+
return getSelectedItemsLabel();
896+
}
900897

901-
return '';
898+
if (ObjectUtils.isArray(props.value)) {
899+
return props.value.reduce((acc, value, index) => acc + (index !== 0 ? ', ' : '') + getLabelByValue(value), '');
902900
}
903901

904-
return label;
902+
return '';
905903
};
906904

907905
const getLabelContent = () => {

0 commit comments

Comments
 (0)