diff --git a/.changeset/tough-toes-camp.md b/.changeset/tough-toes-camp.md new file mode 100644 index 00000000..bf3a1f53 --- /dev/null +++ b/.changeset/tough-toes-camp.md @@ -0,0 +1,5 @@ +--- +"@guardian/cql": patch +--- + +Remove magic number causing succeeding text to be removedwhen chips are deleted with a click diff --git a/lib/cql/src/cqlInput/editor/nodeView.ts b/lib/cql/src/cqlInput/editor/nodeView.ts index 1d911dd5..d9c16961 100644 --- a/lib/cql/src/cqlInput/editor/nodeView.ts +++ b/lib/cql/src/cqlInput/editor/nodeView.ts @@ -45,7 +45,7 @@ export const chipNodeView: NodeViewConstructor = ( const { node, pos } = result; - removeChipCoveringRange(pos, pos + node.nodeSize + 1)(view.state, view.dispatch); + removeChipCoveringRange(pos, pos + node.nodeSize)(view.state, view.dispatch); }; const handlePolarityClickEvent = () => { diff --git a/lib/cql/src/cqlInput/editor/plugins/cql.spec.ts b/lib/cql/src/cqlInput/editor/plugins/cql.spec.ts index 1a70209d..9e374460 100644 --- a/lib/cql/src/cqlInput/editor/plugins/cql.spec.ts +++ b/lib/cql/src/cqlInput/editor/plugins/cql.spec.ts @@ -1014,12 +1014,12 @@ describe("cql plugin", () => { }); it("removes the chip via click", async () => { - const { editor, waitFor } = createCqlEditor("+tag:a"); + const { editor, waitFor } = createCqlEditor("before +tag:a after"); const deleteBtn = await findByText(editor.view.dom, "×"); await fireEvent.click(deleteBtn); - await waitFor(""); + await waitFor("before after"); }); });