diff --git a/src/lib/draw/area/AreaControls.svelte b/src/lib/draw/area/AreaControls.svelte index 36812c6..1f96c4c 100644 --- a/src/lib/draw/area/AreaControls.svelte +++ b/src/lib/draw/area/AreaControls.svelte @@ -222,14 +222,24 @@ let tag = (e.target as HTMLElement).tagName; let formFocused = tag == "INPUT" || tag == "TEXTAREA"; - if (e.key === "Enter" && !formFocused) { + if (e.key == "Enter" && !formFocused) { e.stopPropagation(); if ($waypoints.length >= 3) { finish(); + } else { + window.alert( + "You can't save this area unless it has at least three points. Press 'Cancel' to discard these changes.", + ); } - } else if (e.key === "Escape") { + } else if (e.key == "Escape") { e.stopPropagation(); - cancel(); + if ($waypoints.length >= 3) { + finish(); + } else { + window.alert( + "You can't save this area unless it has at least three points. Press 'Cancel' to discard these changes.", + ); + } } else if (e.key == "s" && !formFocused) { toggleSnap(); } else if (e.key == "z" && e.ctrlKey) { @@ -315,11 +325,9 @@
  • Enter - to finish -
  • -
  • + or Escape - to cancel + to finish
  • diff --git a/src/lib/draw/point/PointControls.svelte b/src/lib/draw/point/PointControls.svelte index f101f09..fdba4c7 100644 --- a/src/lib/draw/point/PointControls.svelte +++ b/src/lib/draw/point/PointControls.svelte @@ -33,9 +33,15 @@ } function keyDown(e: KeyboardEvent) { - if (e.key === "Escape") { + if (e.key == "Escape") { e.stopPropagation(); - cancel(); + if ($pointPosition) { + finish(); + } else { + window.alert( + "You can't save this point until you place it on the map. Press 'Cancel' to discard these changes.", + ); + } } } diff --git a/src/lib/draw/route/RouteControls.svelte b/src/lib/draw/route/RouteControls.svelte index e37b14a..ac2b33e 100644 --- a/src/lib/draw/route/RouteControls.svelte +++ b/src/lib/draw/route/RouteControls.svelte @@ -231,14 +231,24 @@ let tag = (e.target as HTMLElement).tagName; let formFocused = tag == "INPUT" || tag == "TEXTAREA"; - if (e.key === "Enter" && !formFocused) { + if (e.key == "Enter" && !formFocused) { e.stopPropagation(); if ($waypoints.length >= 2) { finish(); + } else { + window.alert( + "You can't save this route unless it has at least two points. Press 'Cancel' to discard these changes.", + ); } - } else if (e.key === "Escape") { + } else if (e.key == "Escape") { e.stopPropagation(); - cancel(); + if ($waypoints.length >= 2) { + finish(); + } else { + window.alert( + "You can't save this route unless it has at least two points. Press 'Cancel' to discard these changes.", + ); + } } else if (e.key == "s" && !formFocused) { toggleSnap(); } else if (e.key == "1" && !formFocused) { @@ -347,11 +357,9 @@
  • Enter - to finish -
  • -
  • + or Escape - to cancel + to finish