Fix issue with radio widget crashing (#922)

* fix types

* Options Validaor checks for empty values

Fixes: #662

Co-authored-by: Sanchit Jain <171220040@nitdelhi.ac.in>
This commit is contained in:
Hetu Nandu 2020-10-05 12:57:44 +05:30 committed by GitHub
parent 1b8b3f7bbe
commit 858db968f6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 3 deletions

View File

@ -58,7 +58,7 @@ class RadioGroupComponent extends React.Component<RadioGroupComponentProps> {
className={this.props.isLoading ? "bp3-skeleton" : ""}
label={option.label}
value={option.value}
key={option.id}
key={option.value}
/>
);
})}

View File

@ -365,7 +365,12 @@ export const VALIDATORS: Record<ValidationType, Validator> = {
}
const hasOptions = _.every(parsed, (datum: { label: any; value: any }) => {
if (_.isObject(datum)) {
return _.isString(datum.label) && _.isString(datum.value);
return (
_.isString(datum.label)
&& _.isString(datum.value)
&& !_.isEmpty(datum.label)
&& !_.isEmpty(datum.value)
);
} else {
return false;
}

View File

@ -84,7 +84,6 @@ class RadioGroupWidget extends BaseWidget<RadioGroupWidgetProps, WidgetState> {
export interface RadioOption {
label: string;
value: string;
id: string;
}
export interface RadioGroupWidgetProps extends WidgetProps {