Skip to content

Commit

Permalink
Fix clear button in inline relationships in the document editor (#6944)
Browse files Browse the repository at this point in the history
  • Loading branch information
emmatown authored Nov 16, 2021
1 parent 528cc5e commit 2be0e18
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
5 changes: 5 additions & 0 deletions .changeset/witty-pillows-report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@keystone-next/fields-document': patch
---

Fixed clear button in inline relationships
11 changes: 6 additions & 5 deletions packages/fields-document/src/DocumentEditor/relationship.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -127,11 +127,12 @@ export function RelationshipElement({
? null
: { id: element.data.id, label: element.data.label || element.data.id },
onChange(value) {
Transforms.setNodes(
editor,
{ data: value },
{ at: ReactEditor.findPath(editor, element) }
);
const at = ReactEditor.findPath(editor, element);
if (value === null) {
Transforms.removeNodes(editor, { at });
} else {
Transforms.setNodes(editor, { data: value }, { at });
}
},
}}
/>
Expand Down

0 comments on commit 2be0e18

Please sign in to comment.