From 43fcefbfa946911de613946dceef19076449c34c Mon Sep 17 00:00:00 2001 From: Ian Jones Date: Thu, 1 Oct 2026 14:04:35 +0100 Subject: [PATCH] fix: Restore right-click delete after merge with undo/delete controls --- src/components/my-map/index.ts | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/components/my-map/index.ts b/src/components/my-map/index.ts index 399815b..b3a89df 100644 --- a/src/components/my-map/index.ts +++ b/src/components/my-map/index.ts @@ -429,8 +429,12 @@ export class MyMap extends LitElement { // Track whether a shape is part-way through being drawn let isSketching = false; - draw.on("drawstart", () => (isSketching = true)); - draw.on(["drawend", "drawabort"], () => (isSketching = false)); + draw.on("drawstart", () => { + isSketching = true; + }); + draw.on(["drawend", "drawabort"], () => { + isSketching = false; + }); const handleDelete = () => { if (isSketching) draw.abortDrawing(); @@ -643,11 +647,6 @@ export class MyMap extends LitElement { // Snap must be added after draw and modify map.addInteraction(snap); - // Track whether a polygon is part-way through being drawn - let isDrawing = false; - draw.on("drawstart", () => (isDrawing = true)); - draw.on(["drawend", "drawabort"], () => (isDrawing = false)); - // Delete the point under the draw pointer, returning whether one was deleted const deletePointAtPixel = (pixel: number[]): boolean => { // Only delete when close enough to the point's centre for Modify to show the draw pointer @@ -686,7 +685,7 @@ export class MyMap extends LitElement { // Right-click to undo the last vertex while drawing, or delete the point/vertex under the draw pointer map.getViewport().addEventListener("contextmenu", (event) => { - if (isDrawing) { + if (isSketching) { event.preventDefault(); draw.removeLastPoint(); return;