Skip to content

Commit

Permalink
fix: fix incorrect placeholder when both hideOnBlur and composing occurs
Browse files Browse the repository at this point in the history
  • Loading branch information
yf-yang committed Sep 14, 2024
1 parent 1ba3feb commit 5e4b047
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': minor
---

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 5e4b047

Please sign in to comment.