From b7cd279afa16c7b2c571fbc4ccba8242215bc94d Mon Sep 17 00:00:00 2001 From: Jonathon Herbert Date: Wed, 4 Mar 2026 16:39:50 +0000 Subject: [PATCH 1/3] Amend test for click delete to include text around chip --- lib/cql/src/cqlInput/editor/plugins/cql.spec.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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"); }); }); From dac1aeaaa2bed3f75388ce35a216ada18997478c Mon Sep 17 00:00:00 2001 From: Jonathon Herbert Date: Wed, 4 Mar 2026 16:36:12 +0000 Subject: [PATCH 2/3] Remove magic number causing succeeding text to be removedwhen chips are deleted with a click Fixes https://github.com/guardian/cql/issues/114 --- lib/cql/src/cqlInput/editor/nodeView.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 = () => { From 8a92cf71a59d7e0f709733672ec2c24d92b284cc Mon Sep 17 00:00:00 2001 From: Jonathon Herbert Date: Wed, 4 Mar 2026 16:36:53 +0000 Subject: [PATCH 3/3] Add changeset --- .changeset/tough-toes-camp.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/tough-toes-camp.md 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