@trackunit/react-map-draw 0.0.53 → 0.0.55

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,14 +1,14 @@
1
1
  {
2
2
  "name": "@trackunit/react-map-draw",
3
- "version": "0.0.53",
3
+ "version": "0.0.55",
4
4
  "repository": "https://github.com/Trackunit/manager",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "engines": {
7
7
  "node": ">=24.x"
8
8
  },
9
9
  "dependencies": {
10
- "@trackunit/react-map-adapter-shared": "0.0.215",
11
- "@trackunit/geo-json-utils": "1.21.47",
10
+ "@trackunit/react-map-adapter-shared": "0.0.216",
11
+ "@trackunit/geo-json-utils": "1.21.48",
12
12
  "es-toolkit": "^1.52.0",
13
13
  "terra-draw": "^1.36.0"
14
14
  },
@@ -225,12 +225,21 @@ const createTerraDrawEngine = ({ adapter, style }) => {
225
225
  /**
226
226
  * `change` fires per pointer move while drawing and per frame while dragging, so
227
227
  * only feature deletions are taken from it; those have no `finish` of their own.
228
+ *
229
+ * A `delete` is not always a polygon going away: Terra Draw also deletes guidance
230
+ * points, and it does so halfway through closing a polygon, after the polygon has
231
+ * stopped being `currentlyDrawing` and before `finish`. Reporting from there would
232
+ * run listeners inside Terra Draw's `close()`, and a listener that leaves polygon
233
+ * mode then makes the mode clean up the polygon it is still closing (SAGA-1035).
234
+ * So a deletion is reported only when a committed polygon is actually gone.
228
235
  */
229
236
  const handleChange = (_ids, type) => {
230
237
  if (!ready || applying || destroyed)
231
238
  return;
232
239
  if (type !== "delete")
233
240
  return;
241
+ if (toDrawValue(draw.getSnapshot()).features.length >= lastEmitted.features.length)
242
+ return;
234
243
  emitIfChanged();
235
244
  };
236
245
  const handleReady = () => {
@@ -223,12 +223,21 @@ const createTerraDrawEngine = ({ adapter, style }) => {
223
223
  /**
224
224
  * `change` fires per pointer move while drawing and per frame while dragging, so
225
225
  * only feature deletions are taken from it; those have no `finish` of their own.
226
+ *
227
+ * A `delete` is not always a polygon going away: Terra Draw also deletes guidance
228
+ * points, and it does so halfway through closing a polygon, after the polygon has
229
+ * stopped being `currentlyDrawing` and before `finish`. Reporting from there would
230
+ * run listeners inside Terra Draw's `close()`, and a listener that leaves polygon
231
+ * mode then makes the mode clean up the polygon it is still closing (SAGA-1035).
232
+ * So a deletion is reported only when a committed polygon is actually gone.
226
233
  */
227
234
  const handleChange = (_ids, type) => {
228
235
  if (!ready || applying || destroyed)
229
236
  return;
230
237
  if (type !== "delete")
231
238
  return;
239
+ if (toDrawValue(draw.getSnapshot()).features.length >= lastEmitted.features.length)
240
+ return;
232
241
  emitIfChanged();
233
242
  };
234
243
  const handleReady = () => {