Skip to content

Commit

Permalink
Warn about display: flex container for the editor
Browse files Browse the repository at this point in the history
  • Loading branch information
fantactuka committed Dec 3, 2024
1 parent a9dfc93 commit 91bbbed
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions packages/lexical/src/LexicalEditor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1070,6 +1070,19 @@ export class LexicalEditor {
if (classNames != null) {
nextRootElement.classList.add(...classNames);
}
if (__DEV__) {
const nextRootElementParent = nextRootElement.parentElement;
if (
nextRootElementParent != null &&
['flex', 'inline-flex'].includes(
getComputedStyle(nextRootElementParent).display,
)
) {
console.warn(
`When using "display: flex" or "display: inline-flex" on an element containing content editable, Chrome may have unwanted focusing behavior when clicking outside of it. Consider wrapping the content editable within a non-flex element.`,
);
}
}
} else {
// If content editable is unmounted we'll reset editor state back to original
// (or pending) editor state since there will be no reconciliation
Expand Down

0 comments on commit 91bbbed

Please sign in to comment.