facebook / facebook/lexical

Bug: Lexical adds word-break and white-space properties which cause different rendering

Open
#4,255 3 comments 1 reaction 0 assignees View on GitHub
all-platforms-bug core
Dominant language
TypeScript
Stars
23.9k
Forks
2.2k
Avg merge
1d 14h
Merged PRs (30d)
55

Description

By default lexical adds white-space: pre-wrap and word-break: break-word to the editor element to function properly. We are planning to use Lexical in a visual editor, where you can inline edit texts with Lexical. After the editing done, we destroy Lexical. The problem is when we init or destroy the Lexical editor, there is a moment of change in the text as the default white-space and word-break value is different. You can see on the following video when entering/leaving Lexical, there is a small horizontal jump in the first line of text.

Screen recording: https://youtu.be/AjeoYTn5Tgg

```
requestAnimationFrame(() => {
blockElement.style.removeProperty('white-space'); // We must remove Lexical white-space:pre-wrap to give identical result during editing.
blockElement.style.removeProperty('word-break'); // We must remove Lexical word-break: break-word to give identical result during editing.
});
```
If we remove those two properties the editor fails to create space-s after specific blocks. For example if your cursor is after an `````` tag, then you can not create space after that, but you can type.

Related to: https://github.com/facebook/lexical/issues/71

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.