diff --git a/src/platform/packages/private/kbn-esql-editor/src/esql_editor.tsx b/src/platform/packages/private/kbn-esql-editor/src/esql_editor.tsx index 628bab839bdb9..dcb958311a85d 100644 --- a/src/platform/packages/private/kbn-esql-editor/src/esql_editor.tsx +++ b/src/platform/packages/private/kbn-esql-editor/src/esql_editor.tsx @@ -84,6 +84,7 @@ export const ESQLEditor = memo(function ESQLEditor({ hideQueryHistory, hasOutline, displayDocumentationAsFlyout, + disableAutoFocus, }: ESQLEditorProps) { const popoverRef = useRef(null); const datePickerOpenStatusRef = useRef(false); @@ -727,8 +728,10 @@ export const ESQLEditor = memo(function ESQLEditor({ editor.onDidChangeModelContent(showSuggestionsIfEmptyQuery); // Auto-focus the editor and move the cursor to the end. - editor.focus(); - editor.setPosition({ column: Infinity, lineNumber: Infinity }); + if (!disableAutoFocus) { + editor.focus(); + editor.setPosition({ column: Infinity, lineNumber: Infinity }); + } }} /> diff --git a/src/platform/packages/private/kbn-esql-editor/src/types.ts b/src/platform/packages/private/kbn-esql-editor/src/types.ts index a5fcaba885b0a..d1cd894ebfd37 100644 --- a/src/platform/packages/private/kbn-esql-editor/src/types.ts +++ b/src/platform/packages/private/kbn-esql-editor/src/types.ts @@ -66,6 +66,9 @@ export interface ESQLEditorProps { /** adds a documentation icon in the footer which opens the inline docs as a flyout **/ displayDocumentationAsFlyout?: boolean; + + /** The component by default focuses on the editor when it is mounted, this flag disables it**/ + disableAutoFocus?: boolean; } export interface ESQLEditorDeps {