diff --git a/gui/src/components/mainInput/tiptap/TipTapEditor.tsx b/gui/src/components/mainInput/tiptap/TipTapEditor.tsx index 7a7b3d8e1..722cb007c 100644 --- a/gui/src/components/mainInput/tiptap/TipTapEditor.tsx +++ b/gui/src/components/mainInput/tiptap/TipTapEditor.tsx @@ -153,14 +153,24 @@ function TipTapEditor(props: TipTapEditorProps) { setActiveKey, }); + const handleBlur = (e: React.FocusEvent) => { + // Check if the new focus target is within our InputBoxDiv + const currentTarget = e.currentTarget; + const relatedTarget = e.relatedTarget as Node | null; + + if (relatedTarget && currentTarget.contains(relatedTarget)) { + return; + } + + setShouldHideToolbar(true); + }; + return ( { setShouldHideToolbar(false); }} - onBlur={() => { - setShouldHideToolbar(true); - }} + onBlur={handleBlur} onKeyDown={handleKeyDown} onKeyUp={handleKeyUp} className={shouldHideToolbar ? "cursor-default" : "cursor-text"}