diff --git a/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_creation/components/details_step/details_step_form.tsx b/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_creation/components/details_step/details_step_form.tsx index 064b182200f45..2a86ea3f723c6 100644 --- a/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_creation/components/details_step/details_step_form.tsx +++ b/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_creation/components/details_step/details_step_form.tsx @@ -61,7 +61,7 @@ export const DetailsStepForm: FC = ({ } = form; const [destIndexSameAsId, setDestIndexSameAsId] = useState( - cloneJob === undefined && hasSwitchedToEditor === false + hasSwitchedToEditor === false && destinationIndex !== undefined && destinationIndex === jobId ); const [useResultsFieldDefault, setUseResultsFieldDefault] = useState( (cloneJob === undefined && hasSwitchedToEditor === false && resultsField === undefined) || @@ -178,8 +178,6 @@ export const DetailsStepForm: FC = ({ useEffect(() => { if (destIndexSameAsId === true && !jobIdEmpty && jobIdValid) { setFormState({ destinationIndex: jobId }); - } else if (destIndexSameAsId === false && hasSwitchedToEditor === false) { - setFormState({ destinationIndex: '' }); } // eslint-disable-next-line react-hooks/exhaustive-deps }, [destIndexSameAsId, jobId]); diff --git a/x-pack/test/functional/apps/ml/data_frame_analytics/cloning.ts b/x-pack/test/functional/apps/ml/data_frame_analytics/cloning.ts index 279853d280dce..19baea2c48c1f 100644 --- a/x-pack/test/functional/apps/ml/data_frame_analytics/cloning.ts +++ b/x-pack/test/functional/apps/ml/data_frame_analytics/cloning.ts @@ -197,6 +197,9 @@ export default function ({ getService }: FtrProviderContext) { testData.job as DataFrameAnalyticsConfig ); await ml.dataFrameAnalyticsCreation.setJobId(cloneJobId); + // open the dest index input + await ml.dataFrameAnalyticsCreation.assertDestIndexSameAsIdSwitchExists(); + await ml.dataFrameAnalyticsCreation.setDestIndexSameAsIdCheckState(false); await ml.dataFrameAnalyticsCreation.setDestIndex(cloneDestIndex); await ml.testExecution.logTestStep('should continue to the validation step'); diff --git a/x-pack/test/functional/services/ml/data_frame_analytics_creation.ts b/x-pack/test/functional/services/ml/data_frame_analytics_creation.ts index fe0949c1d123c..43bb799a5a759 100644 --- a/x-pack/test/functional/services/ml/data_frame_analytics_creation.ts +++ b/x-pack/test/functional/services/ml/data_frame_analytics_creation.ts @@ -716,7 +716,8 @@ export function MachineLearningDataFrameAnalyticsCreationProvider( async assertInitialCloneJobDetailsStep(job: DataFrameAnalyticsConfig) { await this.assertJobIdValue(''); // id should be empty await this.assertJobDescriptionValue(String(job.description)); - await this.assertDestIndexValue(''); // destination index should be empty + // destination index same as id should be checked since dest index is reset to '' on clone + await this.assertDestIndexSameAsIdCheckState(true); }, async assertCreationCalloutMessagesExist() {