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>
This commit is contained in:
David Luzar 2022-11-02 14:52:32 +01:00 committed by GitHub
parent 6c15d9948b
commit 8d5d68e589
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -72,12 +72,16 @@ export const actionDeleteSelected = register({
if (!element) { if (!element) {
return false; return false;
} }
if ( // case: no point selected → do nothing, as deleting the whole element
// case: no point selected → delete whole element // is most likely a mistake, where you wanted to delete a specific point
selectedPointsIndices == null || // but failed to select it (or you thought it's selected, while it was
// case: deleting last remaining point // only in a hover state)
element.points.length < 2 if (selectedPointsIndices == null) {
) { return false;
}
// case: deleting last remaining point
if (element.points.length < 2) {
const nextElements = elements.map((el) => { const nextElements = elements.map((el) => {
if (el.id === element.id) { if (el.id === element.id) {
return newElementWith(el, { isDeleted: true }); return newElementWith(el, { isDeleted: true });