Skip to content

Commit

Permalink
ensure depvar options are loaded before showing options box
Browse files Browse the repository at this point in the history
  • Loading branch information
alvarezmelissa87 committed Sep 10, 2020
1 parent e2cbd89 commit 255bb5b
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ export const ConfigurationStepForm: FC<CreateAnalyticsStepProps> = ({
const [loadingFieldOptions, setLoadingFieldOptions] = useState<boolean>(false);
const [fieldOptionsFetchFail, setFieldOptionsFetchFail] = useState<boolean>(false);
const [loadingDepVarOptions, setLoadingDepVarOptions] = useState<boolean>(false);
const [loadedDepVarOptions, setLoadedDepVarOptions] = useState<boolean>(false);
const [dependentVariableFetchFail, setDependentVariableFetchFail] = useState<boolean>(false);
const [dependentVariableOptions, setDependentVariableOptions] = useState<
EuiComboBoxOptionOption[]
Expand Down Expand Up @@ -124,7 +125,7 @@ export const ConfigurationStepForm: FC<CreateAnalyticsStepProps> = ({
requiredFieldsError !== undefined ||
unsupportedFieldsError !== undefined;

const loadDepVarOptions = async (formState: State['form']) => {
const loadDepVarOptions = (formState: State['form']) => {
setLoadingDepVarOptions(true);
setMaxDistinctValuesError(undefined);

Expand Down Expand Up @@ -152,11 +153,13 @@ export const ConfigurationStepForm: FC<CreateAnalyticsStepProps> = ({
depVarUpdate = '';
}
setDependentVariableOptions(depVarOptions);
setLoadedDepVarOptions(true);
setLoadingDepVarOptions(false);
setDependentVariableFetchFail(false);
setFormState({ dependentVariable: depVarUpdate });
}
} catch (e) {
setLoadedDepVarOptions(true);
setLoadingDepVarOptions(false);
setDependentVariableFetchFail(true);
}
Expand Down Expand Up @@ -331,7 +334,7 @@ export const ConfigurationStepForm: FC<CreateAnalyticsStepProps> = ({
>
<DataGrid {...indexPreviewProps} />
</EuiFormRow>
{isJobTypeWithDepVar && (
{isJobTypeWithDepVar && loadedDepVarOptions && (
<Fragment>
<EuiFormRow
fullWidth
Expand Down

0 comments on commit 255bb5b

Please sign in to comment.