diff --git a/app/client/src/widgets/DropdownWidget.tsx b/app/client/src/widgets/DropdownWidget.tsx index 71221e3d20..88b87441ee 100644 --- a/app/client/src/widgets/DropdownWidget.tsx +++ b/app/client/src/widgets/DropdownWidget.tsx @@ -21,6 +21,7 @@ class DropdownWidget extends BaseWidget { selectionType: VALIDATION_TYPES.TEXT, selectedIndexArr: VALIDATION_TYPES.ARRAY, isRequired: VALIDATION_TYPES.BOOLEAN, + defaultOptionValue: VALIDATION_TYPES.TEXT, }; } static getDerivedPropertiesMap() { @@ -64,18 +65,21 @@ class DropdownWidget extends BaseWidget { ) { this.updateWidgetMetaProperty("selectedIndex", undefined); this.updateWidgetMetaProperty("selectedIndexArr", []); - } else if ( - (this.props.selectedIndex !== prevProps.selectedIndex && - this.props.selectedIndex === undefined) || - this.props.defaultOptionValue !== prevProps.defaultOptionValue - ) { - const selectedIndex = _.findIndex(this.props.options, option => { - return option.value === this.props.defaultOptionValue; - }); - if (selectedIndex > -1) { - this.updateWidgetMetaProperty("selectedIndex", selectedIndex); - } else { - this.updateWidgetMetaProperty("selectedIndex", undefined); + } + if (this.props.defaultOptionValue) { + if ( + (this.props.selectedIndex !== prevProps.selectedIndex && + this.props.selectedIndex === undefined) || + this.props.defaultOptionValue !== prevProps.defaultOptionValue + ) { + const selectedIndex = _.findIndex(this.props.options, option => { + return option.value === this.props.defaultOptionValue; + }); + if (selectedIndex > -1) { + this.updateWidgetMetaProperty("selectedIndex", selectedIndex); + } else { + this.updateWidgetMetaProperty("selectedIndex", undefined); + } } } }