Fix triggering of onChange when value is the same (#892)

Fixes: #710
This commit is contained in:
Nicholas 2020-10-03 17:52:59 +08:00 committed by GitHub
parent 09106780aa
commit 052bd2a5e3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -136,11 +136,15 @@ class DropdownWidget extends BaseWidget<DropdownWidgetProps, WidgetState> {
}
onOptionSelected = (selectedOption: DropdownOption) => {
let isChanged = true;
if (this.props.selectionType === "SINGLE_SELECT") {
this.updateWidgetMetaProperty(
"selectedOptionValue",
selectedOption.value,
);
isChanged = !(this.props.selectedOption.value == selectedOption.value);
if (isChanged) {
this.updateWidgetMetaProperty(
"selectedOptionValue",
selectedOption.value,
);
}
} else if (this.props.selectionType === "MULTI_SELECT") {
const isAlreadySelected = this.props.selectedOptionValueArr.includes(
selectedOption.value,
@ -156,7 +160,8 @@ class DropdownWidget extends BaseWidget<DropdownWidgetProps, WidgetState> {
}
this.updateWidgetMetaProperty("selectedOptionValueArr", newSelectedValue);
}
if (this.props.onOptionChange) {
if (this.props.onOptionChange && isChanged) {
super.executeAction({
dynamicString: this.props.onOptionChange,
event: {