[MM-38103] initialize select fields with the value (#5640)

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
This commit is contained in:
Jason Frerich 2022-08-04 14:28:27 -05:00 committed by GitHub
parent 8cbf57781b
commit 0165e2ab1f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -52,7 +52,34 @@ export default class AppsFormField extends React.PureComponent<Props, State> {
constructor(props: Props) {
super(props);
this.state = {};
let selected;
switch (props.field.type) {
case AppFieldTypes.STATIC_SELECT:
case AppFieldTypes.DYNAMIC_SELECT:
case AppFieldTypes.USER:
case AppFieldTypes.CHANNEL: {
const value = props.value as AppSelectOption[] | AppSelectOption | null;
if (value) {
if (Array.isArray(value)) {
selected = value.map((option) => {
return {
text: option.label,
value: option.value,
};
});
} else {
selected = {
text: value.label,
value: value.value,
};
}
}
}
}
this.state = {
selected,
};
}
handleAutocompleteSelect = (selected: DialogOption) => {