diff --git a/x-pack/packages/kbn-elastic-assistant/impl/assistant/prompt_textarea/index.tsx b/x-pack/packages/kbn-elastic-assistant/impl/assistant/prompt_textarea/index.tsx index 5787847043cf..7ecec0d72900 100644 --- a/x-pack/packages/kbn-elastic-assistant/impl/assistant/prompt_textarea/index.tsx +++ b/x-pack/packages/kbn-elastic-assistant/impl/assistant/prompt_textarea/index.tsx @@ -30,13 +30,16 @@ export const PromptTextArea = forwardRef( const onKeyDown = useCallback( (event) => { - if (event.key === 'Enter' && !event.shiftKey && value.trim().length > 0) { + // keyCode 13 is needed in case of IME input + if (event.keyCode === 13 && !event.shiftKey) { event.preventDefault(); - onPromptSubmit(event.target.value?.trim()); - handlePromptChange(''); - } else if (event.key === 'Enter' && !event.shiftKey && value.trim().length === 0) { - event.preventDefault(); - event.stopPropagation(); + + if (value.trim().length) { + onPromptSubmit(event.target.value?.trim()); + handlePromptChange(''); + } else { + event.stopPropagation(); + } } }, [value, onPromptSubmit, handlePromptChange]