From 8d5d68e5894ea4b65539051da2e047f28a20fab6 Mon Sep 17 00:00:00 2001 From: David Luzar Date: Wed, 2 Nov 2022 14:52:32 +0100 Subject: [PATCH] feat: stop deleting whole line when no point select in line editor (#5676) * feat: stop deleting whole line when no point select in line editor * Comments typo Co-authored-by: DanielJGeiger <1852529+DanielJGeiger@users.noreply.github.com> --- src/actions/actionDeleteSelected.tsx | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/actions/actionDeleteSelected.tsx b/src/actions/actionDeleteSelected.tsx index 0dd77f4a..a1820a33 100644 --- a/src/actions/actionDeleteSelected.tsx +++ b/src/actions/actionDeleteSelected.tsx @@ -72,12 +72,16 @@ export const actionDeleteSelected = register({ if (!element) { return false; } - if ( - // case: no point selected → delete whole element - selectedPointsIndices == null || - // case: deleting last remaining point - element.points.length < 2 - ) { + // case: no point selected → do nothing, as deleting the whole element + // is most likely a mistake, where you wanted to delete a specific point + // but failed to select it (or you thought it's selected, while it was + // only in a hover state) + if (selectedPointsIndices == null) { + return false; + } + + // case: deleting last remaining point + if (element.points.length < 2) { const nextElements = elements.map((el) => { if (el.id === element.id) { return newElementWith(el, { isDeleted: true });