Skip to content

Commit

Permalink
Merge pull request #3536 from yf-yang/fix-composing
Browse files Browse the repository at this point in the history
fix: fix incorrect placeholder when both hideOnBlur and composing occurs
  • Loading branch information
zbeyens authored Sep 14, 2024
2 parents 1ba3feb + 551e310 commit 6b18ed1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
5 changes: 5 additions & 0 deletions .changeset/twenty-cows-count.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@udecode/plate-utils': patch
---

Suppress all placeholders when element is composing
8 changes: 2 additions & 6 deletions packages/plate-utils/src/react/usePlaceholder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,13 @@ export const usePlaceholderState = ({
const composing = useComposing();
const editor = useEditorRef();

const isEmptyBlock = isElementEmpty(editor, element);
const isEmptyBlock = isElementEmpty(editor, element) && !composing;

const enabled =
isEmptyBlock &&
(!query || queryNode([element, findNodePath(editor, element)!], query)) &&
(!hideOnBlur ||
(isCollapsed(editor.selection) &&
hideOnBlur &&
focused &&
selected &&
!composing));
(isCollapsed(editor.selection) && hideOnBlur && focused && selected));

return {
enabled,
Expand Down

0 comments on commit 6b18ed1

Please sign in to comment.