From 400334bc2289bf8457642d9767ba21cde7099f3c Mon Sep 17 00:00:00 2001 From: saarikabhasi Date: Mon, 9 Dec 2024 11:47:04 -0500 Subject: [PATCH] clean up --- .../document_fields/field_parameters/type_parameter.tsx | 2 +- .../document_fields/fields/edit_field/edit_field.tsx | 6 ------ .../fields/edit_field/edit_field_header_form.tsx | 9 ++------- .../components/document_fields/fields_tree_editor.tsx | 5 +---- 4 files changed, 4 insertions(+), 18 deletions(-) diff --git a/x-pack/plugins/index_management/public/application/components/mappings_editor/components/document_fields/field_parameters/type_parameter.tsx b/x-pack/plugins/index_management/public/application/components/mappings_editor/components/document_fields/field_parameters/type_parameter.tsx index 665922779c067..528019416ad69 100644 --- a/x-pack/plugins/index_management/public/application/components/mappings_editor/components/document_fields/field_parameters/type_parameter.tsx +++ b/x-pack/plugins/index_management/public/application/components/mappings_editor/components/document_fields/field_parameters/type_parameter.tsx @@ -24,7 +24,7 @@ interface Props { isMultiField?: boolean | null; showDocLink?: boolean; isSemanticTextEnabled?: boolean; - fieldTypeInputRef: React.MutableRefObject; + fieldTypeInputRef?: React.MutableRefObject; } export const TypeParameter = ({ diff --git a/x-pack/plugins/index_management/public/application/components/mappings_editor/components/document_fields/fields/edit_field/edit_field.tsx b/x-pack/plugins/index_management/public/application/components/mappings_editor/components/document_fields/fields/edit_field/edit_field.tsx index ed758a82c50b1..6812d5cef31fd 100644 --- a/x-pack/plugins/index_management/public/application/components/mappings_editor/components/document_fields/fields/edit_field/edit_field.tsx +++ b/x-pack/plugins/index_management/public/application/components/mappings_editor/components/document_fields/fields/edit_field/edit_field.tsx @@ -59,17 +59,12 @@ const FormWrapper: React.FC<{ children?: React.ReactNode }> = ({ children }) => export const EditField = React.memo( ({ form, field, allFields, exitEdit, updateField, kibanaVersion }: Props) => { - const fieldTypeInputRef = useRef(null); - const submitForm = async () => { const { isValid, data } = await form.submit(); if (isValid) { updateField({ ...field, source: data }); } - if (fieldTypeInputRef.current) { - fieldTypeInputRef.current.focus(); - } }; const { isMultiField } = field; @@ -154,7 +149,6 @@ export const EditField = React.memo( defaultValue={field.source} isRootLevelField={field.parentId === undefined} isMultiField={isMultiField} - fieldTypeInputRef={fieldTypeInputRef} /> diff --git a/x-pack/plugins/index_management/public/application/components/mappings_editor/components/document_fields/fields/edit_field/edit_field_header_form.tsx b/x-pack/plugins/index_management/public/application/components/mappings_editor/components/document_fields/fields/edit_field/edit_field_header_form.tsx index 963d1d23a65de..6acbfa0371d8c 100644 --- a/x-pack/plugins/index_management/public/application/components/mappings_editor/components/document_fields/fields/edit_field/edit_field_header_form.tsx +++ b/x-pack/plugins/index_management/public/application/components/mappings_editor/components/document_fields/fields/edit_field/edit_field_header_form.tsx @@ -19,7 +19,6 @@ interface Props { defaultValue: Field; isRootLevelField: boolean; isMultiField: boolean; - fieldTypeInputRef: React.MutableRefObject; } const getTypeDefinition = (type: MainType, subType: SubType): DataTypeDefinition | undefined => { @@ -42,7 +41,7 @@ const getTypeDefinition = (type: MainType, subType: SubType): DataTypeDefinition }; export const EditFieldHeaderForm = React.memo( - ({ defaultValue, isRootLevelField, isMultiField, fieldTypeInputRef }: Props) => { + ({ defaultValue, isRootLevelField, isMultiField }: Props) => { return ( <> @@ -53,11 +52,7 @@ export const EditFieldHeaderForm = React.memo( {/* Field type */} - + {/* Field subType (if any) */} diff --git a/x-pack/plugins/index_management/public/application/components/mappings_editor/components/document_fields/fields_tree_editor.tsx b/x-pack/plugins/index_management/public/application/components/mappings_editor/components/document_fields/fields_tree_editor.tsx index a30bd7eacfb7c..9274f10ab603e 100644 --- a/x-pack/plugins/index_management/public/application/components/mappings_editor/components/document_fields/fields_tree_editor.tsx +++ b/x-pack/plugins/index_management/public/application/components/mappings_editor/components/document_fields/fields_tree_editor.tsx @@ -36,10 +36,7 @@ export const DocumentFieldsTreeEditor = ({ const addField = useCallback(() => { dispatch({ type: 'documentField.createField' }); - if (createFieldFormRef.current) { - createFieldFormRef.current.focus(); - } - }, [dispatch, createFieldFormRef.current]); + }, [dispatch]); const renderCreateField = () => { // The "fieldToAddFieldTo" is undefined when adding to the top level "properties" object.