From 731c5a4b091bfe27968b75e42e62b249acbb045c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arturo=20Lidue=C3=B1a?= Date: Wed, 30 Oct 2024 11:45:28 +0100 Subject: [PATCH] [Observability AI Assistant] Input box can be resized off-screen (elastic #181408) (#197063) fixes [181408](https://github.com/elastic/kibana/issues/181408) ## Summary This PR addresses the issue where the Observability AI Assistant input box can be resized outside the boundaries of the browser window. Allows the input box to resize dynamically while ensuring it remains usable, even when the cursor moves outside the screen during resizing. --- .../src/prompt_editor/prompt_editor_natural_language.tsx | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/x-pack/packages/kbn-ai-assistant/src/prompt_editor/prompt_editor_natural_language.tsx b/x-pack/packages/kbn-ai-assistant/src/prompt_editor/prompt_editor_natural_language.tsx index 0b84b504d9507..bdef8c5e3a079 100644 --- a/x-pack/packages/kbn-ai-assistant/src/prompt_editor/prompt_editor_natural_language.tsx +++ b/x-pack/packages/kbn-ai-assistant/src/prompt_editor/prompt_editor_natural_language.tsx @@ -109,6 +109,15 @@ export function PromptEditorNaturalLanguage({ } }, [handleResizeTextArea, prompt]); + useEffect(() => { + // Attach the event listener to the window to catch mouseup outside the browser window + window.addEventListener('mouseup', handleResizeTextArea); + + return () => { + window.removeEventListener('mouseup', handleResizeTextArea); + }; + }, [handleResizeTextArea]); + return (