From c374f4fa200bfbf741727a24d8d200f017dc5664 Mon Sep 17 00:00:00 2001 From: Arindam Biswas <69881224+ArindamBiswas-dev@users.noreply.github.com> Date: Thu, 9 Mar 2023 18:36:37 +0530 Subject: [PATCH] Fix: about section editor (#7287) Co-authored-by: Keith Williams Co-authored-by: Peer Richelsen --- packages/ui/components/editor/Editor.tsx | 2 -- packages/ui/components/editor/plugins/ToolbarPlugin.tsx | 3 ++- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/packages/ui/components/editor/Editor.tsx b/packages/ui/components/editor/Editor.tsx index d66cdeeb96..cd2ffec8ee 100644 --- a/packages/ui/components/editor/Editor.tsx +++ b/packages/ui/components/editor/Editor.tsx @@ -2,7 +2,6 @@ import { CodeHighlightNode, CodeNode } from "@lexical/code"; import { AutoLinkNode, LinkNode } from "@lexical/link"; import { ListItemNode, ListNode } from "@lexical/list"; import { TRANSFORMERS } from "@lexical/markdown"; -import { AutoFocusPlugin } from "@lexical/react/LexicalAutoFocusPlugin"; import { LexicalComposer } from "@lexical/react/LexicalComposer"; import { ContentEditable } from "@lexical/react/LexicalContentEditable"; import { LinkPlugin } from "@lexical/react/LexicalLinkPlugin"; @@ -71,7 +70,6 @@ export const Editor = (props: TextEditorProps) => { contentEditable={} placeholder={
{props.placeholder || ""}
} /> - diff --git a/packages/ui/components/editor/plugins/ToolbarPlugin.tsx b/packages/ui/components/editor/plugins/ToolbarPlugin.tsx index d265e858c9..1c4fe0eb9b 100644 --- a/packages/ui/components/editor/plugins/ToolbarPlugin.tsx +++ b/packages/ui/components/editor/plugins/ToolbarPlugin.tsx @@ -349,11 +349,12 @@ export default function ToolbarPlugin(props: TextEditorProps) { $getRoot().select(); $insertNodes(nodes); - editor.registerUpdateListener(({ editorState }) => { + editor.registerUpdateListener(({ editorState, prevEditorState }) => { editorState.read(() => { const textInHtml = $generateHtmlFromNodes(editor); props.setText(textInHtml); }); + if (!prevEditorState._selection) editor.blur(); }); }); }, []);