diff --git a/packages/lexical/src/LexicalEvents.ts b/packages/lexical/src/LexicalEvents.ts index 36c2bfed985..104576ddbf3 100644 --- a/packages/lexical/src/LexicalEvents.ts +++ b/packages/lexical/src/LexicalEvents.ts @@ -323,6 +323,10 @@ function onSelectionChange( const [lastFormat, lastStyle, lastOffset, lastKey, timeStamp] = collapsedSelectionFormat; + const root = $getRoot(); + const isRootTextContentEmpty = + editor.isComposing() === false && root.getTextContent() === ''; + if ( currentTimeStamp < timeStamp + 200 && anchor.offset === lastOffset && @@ -334,7 +338,7 @@ function onSelectionChange( if (anchor.type === 'text') { selection.format = anchorNode.getFormat(); selection.style = anchorNode.getStyle(); - } else if (anchor.type === 'element') { + } else if (anchor.type === 'element' && !isRootTextContentEmpty) { selection.format = 0; selection.style = ''; }