Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ML] DF Analytics creation wizard: ensure dependent variable options are loaded before showing options box #77202

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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