Skip to content

Commit

Permalink
fix(portable-text-editor): run empty check directly into decorate fn.
Browse files Browse the repository at this point in the history
  • Loading branch information
skogsmaskin authored and rexxars committed Sep 23, 2022
1 parent d020ed1 commit 9fcbc5c
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions packages/@sanity/portable-text-editor/src/editor/Editable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -322,13 +322,8 @@ export const PortableTextEditable = forwardRef(function PortableTextEditable(
}
}, [portableTextEditor, scrollSelectionIntoView])

const isEmpty = useMemo(
() => isEqualToEmptyEditor(slateEditor.children, portableTextFeatures),
[portableTextFeatures, slateEditor.children]
)

const decorate = useCallback(() => {
if (isEmpty) {
if (isEqualToEmptyEditor(slateEditor.children, portableTextFeatures)) {
return [
{
anchor: {
Expand All @@ -344,7 +339,7 @@ export const PortableTextEditable = forwardRef(function PortableTextEditable(
]
}
return EMPTY_DECORATORS
}, [isEmpty])
}, [portableTextFeatures, slateEditor.children])

// The editor
const slateEditable = useMemo(
Expand Down

0 comments on commit 9fcbc5c

Please sign in to comment.