From 6ccde292c4f1ea4d192c98c08588f320665354a8 Mon Sep 17 00:00:00 2001 From: mertsincan Date: Wed, 11 Mar 2020 15:47:15 +0300 Subject: [PATCH] Fixed #1252 - Select components don't correctly return value --- src/components/dropdown/Dropdown.js | 6 +++--- src/components/listbox/ListBox.js | 4 ++-- src/components/multiselect/MultiSelect.js | 6 +++--- src/components/selectbutton/SelectButton.js | 4 ++-- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/components/dropdown/Dropdown.js b/src/components/dropdown/Dropdown.js index 9bc6a97ecd..052f21a261 100644 --- a/src/components/dropdown/Dropdown.js +++ b/src/components/dropdown/Dropdown.js @@ -416,7 +416,7 @@ export class Dropdown extends Component { if(currentSelectedOption !== event.option) { this.updateEditableLabel(event.option); const optionValue = this.getOptionValue(event.option); - + this.props.onChange({ originalEvent: event.originalEvent, value: optionValue, @@ -622,11 +622,11 @@ export class Dropdown extends Component { } getOptionLabel(option) { - return this.props.optionLabel ? ObjectUtils.resolveFieldData(option, this.props.optionLabel) : option.label || option; + return this.props.optionLabel ? ObjectUtils.resolveFieldData(option, this.props.optionLabel) : (option['label'] !== undefined ? option['label'] : option); } getOptionValue(option) { - return this.props.optionValue ? ObjectUtils.resolveFieldData(option, this.props.optionValue) : option.value || option; + return this.props.optionValue ? ObjectUtils.resolveFieldData(option, this.props.optionValue) : (option['value'] !== undefined ? option['value'] : option); } getOptionKey(option) { diff --git a/src/components/listbox/ListBox.js b/src/components/listbox/ListBox.js index b4059cbcd2..8731a62e9d 100644 --- a/src/components/listbox/ListBox.js +++ b/src/components/listbox/ListBox.js @@ -253,11 +253,11 @@ export class ListBox extends Component { } getOptionLabel(option) { - return this.props.optionLabel ? ObjectUtils.resolveFieldData(option, this.props.optionLabel) : option.label || option; + return this.props.optionLabel ? ObjectUtils.resolveFieldData(option, this.props.optionLabel) : (option['label'] !== undefined ? option['label'] : option); } getOptionValue(option) { - return this.props.optionValue ? ObjectUtils.resolveFieldData(option, this.props.optionValue) : option.value || option; + return this.props.optionValue ? ObjectUtils.resolveFieldData(option, this.props.optionValue) : (option['value'] !== undefined ? option['value'] : option); } render() { diff --git a/src/components/multiselect/MultiSelect.js b/src/components/multiselect/MultiSelect.js index ceb347c4b1..ca709e96e0 100644 --- a/src/components/multiselect/MultiSelect.js +++ b/src/components/multiselect/MultiSelect.js @@ -382,11 +382,11 @@ export class MultiSelect extends Component { } getOptionLabel(option) { - return this.props.optionLabel ? ObjectUtils.resolveFieldData(option, this.props.optionLabel) : option.label || option; + return this.props.optionLabel ? ObjectUtils.resolveFieldData(option, this.props.optionLabel) : (option['label'] !== undefined ? option['label'] : option); } getOptionValue(option) { - return this.props.optionValue ? ObjectUtils.resolveFieldData(option, this.props.optionValue) : option.value || option; + return this.props.optionValue ? ObjectUtils.resolveFieldData(option, this.props.optionValue) : (option['value'] !== undefined ? option['value'] : option); } isEmpty() { @@ -458,7 +458,7 @@ export class MultiSelect extends Component { renderHeader(items) { return ( - ); } diff --git a/src/components/selectbutton/SelectButton.js b/src/components/selectbutton/SelectButton.js index 9f556f13a1..d6c0deb1b4 100644 --- a/src/components/selectbutton/SelectButton.js +++ b/src/components/selectbutton/SelectButton.js @@ -121,11 +121,11 @@ export class SelectButton extends Component { } getOptionLabel(option) { - return this.props.optionLabel ? ObjectUtils.resolveFieldData(option, this.props.optionLabel) : option.label || option; + return this.props.optionLabel ? ObjectUtils.resolveFieldData(option, this.props.optionLabel) : (option['label'] !== undefined ? option['label'] : option); } getOptionValue(option) { - return this.props.optionValue ? ObjectUtils.resolveFieldData(option, this.props.optionValue) : option.value || option; + return this.props.optionValue ? ObjectUtils.resolveFieldData(option, this.props.optionValue) : (option['value'] !== undefined ? option['value'] : option); } isSelected(option) {