@defra/interactive-map 0.0.56-alpha → 0.0.57-alpha

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.
Files changed (137) hide show
  1. package/dist/esm/im-core.js +1 -1
  2. package/dist/umd/im-core.js +1 -1
  3. package/dist/umd/index.js +1 -1
  4. package/docs/api/button-definition.md +11 -0
  5. package/docs/api/context.md +2 -0
  6. package/docs/api.md +3 -1
  7. package/docs/plugins/draw.md +189 -33
  8. package/package.json +1 -1
  9. package/plugins/datasets/dist/esm/im-datasets-plugin.js +1 -1
  10. package/plugins/datasets/dist/umd/im-datasets-plugin.js +1 -1
  11. package/plugins/datasets/dist/umd/index.js +1 -1
  12. package/plugins/datasets/src/initialise/DatasetsInit.jsx +6 -17
  13. package/plugins/datasets/src/initialise/DatasetsInit.test.jsx +3 -43
  14. package/plugins/draw/dist/esm/im-draw-ml-adapter.js +1 -1
  15. package/plugins/draw/dist/esm/im-draw-ol-adapter.js +1 -1
  16. package/plugins/draw/dist/esm/im-draw-plugin.js +1 -1
  17. package/plugins/draw/dist/esm/index.js +1 -1
  18. package/plugins/draw/dist/esm/liveDrawChecks.js +1 -1
  19. package/plugins/draw/dist/umd/im-draw-ml-adapter.js +1 -1
  20. package/plugins/draw/dist/umd/im-draw-ol-adapter.js +1 -1
  21. package/plugins/draw/dist/umd/im-draw-plugin.js +1 -1
  22. package/plugins/draw/dist/umd/index.js +1 -1
  23. package/plugins/draw/src/DrawInit.jsx +9 -6
  24. package/plugins/draw/src/DrawInit.test.jsx +15 -0
  25. package/plugins/draw/src/adapterEvents.js +78 -44
  26. package/plugins/draw/src/adapters/adapterContract.test.js +3 -3
  27. package/plugins/draw/src/adapters/maplibre/MaplibreDrawAdapter.js +18 -10
  28. package/plugins/draw/src/adapters/maplibre/MaplibreDrawAdapter.test.js +31 -22
  29. package/plugins/draw/src/adapters/maplibre/drawEvents.js +2 -1
  30. package/plugins/draw/src/adapters/maplibre/modes/drawMode/clickHandlers.js +13 -12
  31. package/plugins/draw/src/adapters/maplibre/modes/drawMode/clickHandlers.test.js +5 -5
  32. package/plugins/draw/src/adapters/maplibre/modes/drawMode/undoHandlers.js +1 -1
  33. package/plugins/draw/src/adapters/maplibre/modes/drawMode/undoHandlers.test.js +2 -2
  34. package/plugins/draw/src/adapters/maplibre/modes/drawPointMode.js +6 -9
  35. package/plugins/draw/src/adapters/maplibre/modes/drawPointMode.test.js +4 -4
  36. package/plugins/draw/src/adapters/maplibre/modes/editPointMode/pointerHandlers.js +6 -9
  37. package/plugins/draw/src/adapters/maplibre/modes/editPointMode/pointerHandlers.test.js +1 -1
  38. package/plugins/draw/src/adapters/maplibre/modes/editPointMode/undoHandlers.js +8 -14
  39. package/plugins/draw/src/adapters/maplibre/modes/editPointMode/undoHandlers.test.js +37 -8
  40. package/plugins/draw/src/adapters/maplibre/modes/editPointMode.js +11 -1
  41. package/plugins/draw/src/adapters/maplibre/modes/editVertexMode/undoHandlers.js +14 -19
  42. package/plugins/draw/src/adapters/maplibre/modes/editVertexMode/undoHandlers.test.js +41 -4
  43. package/plugins/draw/src/adapters/maplibre/modes/editVertexMode.js +12 -1
  44. package/plugins/draw/src/adapters/maplibre/utils/editModeEvents.js +3 -1
  45. package/plugins/draw/src/adapters/maplibre/utils/geometryValidation.js +9 -10
  46. package/plugins/draw/src/adapters/maplibre/utils/geometryValidation.test.js +5 -24
  47. package/plugins/draw/src/adapters/openlayers/OLDrawAdapter.js +10 -7
  48. package/plugins/draw/src/adapters/openlayers/OLDrawAdapter.test.js +12 -7
  49. package/plugins/draw/src/adapters/openlayers/core/OLDrawManager.js +5 -0
  50. package/plugins/draw/src/adapters/openlayers/core/OLDrawManager.test.js +7 -3
  51. package/plugins/draw/src/adapters/openlayers/draw/DrawMode.js +11 -11
  52. package/plugins/draw/src/adapters/openlayers/draw/DrawMode.test.js +15 -15
  53. package/plugins/draw/src/adapters/openlayers/edit/EditMode.js +21 -28
  54. package/plugins/draw/src/adapters/openlayers/edit/EditMode.test.js +26 -5
  55. package/plugins/draw/src/adapters/openlayers/edit/selectionState.js +5 -6
  56. package/plugins/draw/src/adapters/openlayers/edit/selectionState.test.js +2 -12
  57. package/plugins/draw/src/adapters/openlayers/edit/undoOps.js +9 -0
  58. package/plugins/draw/src/adapters/openlayers/edit/undoOps.test.js +7 -0
  59. package/plugins/draw/src/adapters/openlayers/point/drawPointMode.js +6 -9
  60. package/plugins/draw/src/adapters/openlayers/point/drawPointMode.test.js +3 -3
  61. package/plugins/draw/src/adapters/openlayers/point/editPointMode.js +18 -9
  62. package/plugins/draw/src/adapters/openlayers/point/editPointMode.test.js +29 -4
  63. package/plugins/draw/src/adapters/openlayers/point/pointOps.js +3 -2
  64. package/plugins/draw/src/adapters/openlayers/point/pointOps.test.js +6 -0
  65. package/plugins/draw/src/adapters/openlayers/point/pointSelectionState.js +3 -4
  66. package/plugins/draw/src/adapters/openlayers/point/pointSelectionState.test.js +2 -12
  67. package/plugins/draw/src/api/createNewShape.js +4 -4
  68. package/plugins/draw/src/api/createNewShape.test.js +1 -1
  69. package/plugins/draw/src/api/editFeature.js +8 -11
  70. package/plugins/draw/src/api/editFeature.test.js +33 -22
  71. package/plugins/draw/src/api/newLine.test.js +3 -3
  72. package/plugins/draw/src/api/newPoint.js +4 -5
  73. package/plugins/draw/src/api/newPoint.test.js +3 -3
  74. package/plugins/draw/src/api/newPolygon.test.js +3 -3
  75. package/plugins/draw/src/api/recheckGeometry.js +32 -0
  76. package/plugins/draw/src/api/recheckGeometry.test.js +55 -0
  77. package/plugins/draw/src/api/setGeometry.js +33 -0
  78. package/plugins/draw/src/api/setGeometry.test.js +48 -0
  79. package/plugins/draw/src/api/split.js +23 -22
  80. package/plugins/draw/src/api/split.test.js +33 -18
  81. package/plugins/draw/src/events.js +265 -77
  82. package/plugins/draw/src/events.test.js +708 -34
  83. package/plugins/draw/src/hooks/useSpatialList.js +10 -11
  84. package/plugins/draw/src/hooks/useSpatialList.test.js +3 -3
  85. package/plugins/draw/src/manifest.js +30 -15
  86. package/plugins/draw/src/manifest.test.js +91 -9
  87. package/plugins/draw/src/reducer.js +31 -9
  88. package/plugins/draw/src/reducer.test.js +35 -3
  89. package/plugins/draw/src/utils/drawModes.js +27 -0
  90. package/plugins/draw/src/utils/drawModes.test.js +27 -0
  91. package/plugins/draw/src/utils/needsDrawTarget.js +1 -5
  92. package/plugins/draw/src/utils/needsDrawTarget.test.js +1 -11
  93. package/plugins/draw/src/utils/touchTarget.js +34 -26
  94. package/plugins/draw/src/utils/touchTarget.test.js +32 -20
  95. package/plugins/draw/src/validation/commitChecks.js +185 -0
  96. package/plugins/draw/src/validation/commitChecks.test.js +205 -0
  97. package/plugins/draw/src/validation/liveDrawChecks.js +11 -11
  98. package/plugins/draw/src/validation/liveDrawChecks.test.js +37 -37
  99. package/plugins/draw/src/validation/liveStroke.js +6 -6
  100. package/plugins/draw/src/validation/liveStroke.test.js +27 -27
  101. package/plugins/draw/src/validation/rules.js +16 -14
  102. package/plugins/draw/src/validation/rules.test.js +5 -5
  103. package/plugins/draw/src/validation/validateGeometry.js +58 -31
  104. package/plugins/draw/src/validation/validateGeometry.test.js +68 -44
  105. package/plugins/interact/dist/esm/im-interact-plugin.js +1 -1
  106. package/plugins/interact/dist/umd/im-interact-plugin.js +1 -1
  107. package/plugins/interact/dist/umd/index.js +1 -1
  108. package/plugins/interact/src/hooks/useInteractionHandlers.js +3 -5
  109. package/plugins/interact/src/hooks/useInteractionHandlers.test.js +4 -3
  110. package/plugins/interact/src/hooks/useSpatialList.js +16 -17
  111. package/plugins/interact/src/hooks/useSpatialList.test.js +9 -9
  112. package/plugins/map-styles/dist/esm/im-map-styles-plugin.js +1 -1
  113. package/plugins/map-styles/dist/umd/im-map-styles-plugin.js +1 -1
  114. package/plugins/map-styles/src/MapStyles.jsx +2 -2
  115. package/providers/maplibre/dist/esm/index.js +1 -1
  116. package/providers/maplibre/dist/umd/index.js +1 -1
  117. package/providers/maplibre/src/index.js +11 -2
  118. package/providers/maplibre/src/index.test.js +23 -1
  119. package/providers/maplibre/src/utils/detectModuleWorker.js +8 -19
  120. package/providers/maplibre/src/utils/detectModuleWorker.test.js +19 -23
  121. package/providers/maplibre/src/utils/workerUrl.js +12 -0
  122. package/providers/maplibre/src/utils/workerUrl.test.js +14 -1
  123. package/src/App/components/MapButton/MapButton.jsx +6 -0
  124. package/src/App/components/MapButton/MapButton.test.jsx +10 -0
  125. package/src/App/components/Markers/Markers.jsx +3 -5
  126. package/src/App/components/Markers/Markers.test.jsx +9 -11
  127. package/src/App/components/Panel/Panel.jsx +2 -9
  128. package/src/App/hooks/useInterfaceAPI.js +16 -4
  129. package/src/App/hooks/useInterfaceAPI.test.js +66 -1
  130. package/src/App/renderer/mapButtons.js +2 -1
  131. package/src/App/renderer/mapButtons.test.js +9 -0
  132. package/src/App/store/MapProvider.jsx +3 -0
  133. package/src/App/store/MapProvider.test.jsx +24 -0
  134. package/src/config/mapSizeScales.js +3 -0
  135. package/src/types.js +4 -0
  136. package/src/utils/focusAfterPanelClose.js +9 -0
  137. package/src/utils/focusAfterPanelClose.test.js +40 -0
@@ -1,5 +1,6 @@
1
1
  import { splitPolygon } from '../utils/spatial.js'
2
- import { ADAPTER_EVENTS } from '../adapterEvents.js'
2
+ import { ADAPTER_EVENTS, CHANGE_PHASE } from '../adapterEvents.js'
3
+ import { getCommitChecks } from '../validation/commitChecks.js'
3
4
 
4
5
  const INVALID_REASON = 'Line does not split the shape into two parts'
5
6
  const MIN_LINE_VERTICES = 2
@@ -21,29 +22,25 @@ const applySplitPreview = ({ draw, polygonFeature, feature }) => {
21
22
  return isValid
22
23
  }
23
24
 
24
- // Colours the preview and gates Done/the finish gesture for a committed vertex.
25
+ // Colours the preview for a committed vertex and records whether the split is valid.
26
+ // Its returned verdict gates Done and the finish gesture (events.js).
25
27
  const applySplitCommit = ({ draw, dispatch, polygonFeature, feature }) => {
26
28
  const isValid = applySplitPreview({ draw, polygonFeature, feature })
27
29
  dispatch({ type: 'SET_ACTION', payload: { name: 'split', isValid } })
28
- dispatch({ type: 'SET_GEOMETRY_VALID', payload: isValid })
29
- draw.setGeometryValid(isValid)
30
30
  return isValid
31
31
  }
32
32
 
33
- // Installed as draw._geometryValidator. 'place' and 'create' are no-ops — a split
34
- // isn't complete until its last vertex, so checking those would block placement
35
- // and hijack an early finish into edit mode.
36
- const createSplitValidator = ({ draw, dispatch, polygonFeature }) => ({ feature, phase }) => {
37
- let isValid
38
- if (phase === 'preview') {
39
- isValid = applySplitPreview({ draw, polygonFeature, feature })
40
- } else if (phase?.startsWith('commit-')) {
41
- isValid = applySplitCommit({ draw, dispatch, polygonFeature, feature })
42
- } else {
43
- return { valid: true }
44
- }
45
- return isValid ? { valid: true } : { valid: false, reason: INVALID_REASON }
46
- }
33
+ const toResult = (isValid) => (isValid ? { valid: true } : { valid: false, reason: INVALID_REASON })
34
+
35
+ // Installed as draw._previewValidator. 'place' is a no-op — a split isn't complete
36
+ // until its last vertex, so checking it would block placement.
37
+ const createSplitPreviewValidator = ({ draw, polygonFeature }) => ({ feature, phase }) =>
38
+ phase === 'preview' ? toResult(applySplitPreview({ draw, polygonFeature, feature })) : { valid: true }
39
+
40
+ // Installed as draw._commitValidator. 'create' is a no-op — checking it would
41
+ // hijack an early finish into edit mode.
42
+ const createSplitCommitValidator = ({ draw, dispatch, polygonFeature }) => ({ feature, phase }) =>
43
+ phase === CHANGE_PHASE ? toResult(applySplitCommit({ draw, dispatch, polygonFeature, feature })) : { valid: true }
47
44
 
48
45
  /**
49
46
  * Start drawing a split line for a polygon.
@@ -63,9 +60,12 @@ export const split = ({ appState, appConfig, pluginState, mapState, mapProvider,
63
60
 
64
61
  const polygonFeature = draw.get(featureId)
65
62
 
66
- // Swap in split's own rule; restored in stopListening.
67
- const previousValidator = draw._geometryValidator
68
- draw._geometryValidator = createSplitValidator({ draw, dispatch, polygonFeature })
63
+ // Swap in split's own rules; restored in stopListening.
64
+ const previousPreviewValidator = draw._previewValidator
65
+ const previousValidator = draw._commitValidator
66
+ draw._previewValidator = createSplitPreviewValidator({ draw, polygonFeature })
67
+ draw._commitValidator = createSplitCommitValidator({ draw, dispatch, polygonFeature })
68
+ getCommitChecks(draw).reset()
69
69
 
70
70
  // Always include the draw outline layer so the split line snaps to it
71
71
  const snapLayers = ['stroke-inactive.cold', ...(options.snapLayers || [])]
@@ -84,7 +84,8 @@ export const split = ({ appState, appConfig, pluginState, mapState, mapProvider,
84
84
 
85
85
  // Unregister everything scoped to this session.
86
86
  const stopListening = () => {
87
- draw._geometryValidator = previousValidator
87
+ draw._previewValidator = previousPreviewValidator
88
+ draw._commitValidator = previousValidator
88
89
  draw.off(ADAPTER_EVENTS.CREATE, onSplitCreate)
89
90
  draw.off(ADAPTER_EVENTS.CANCEL, onSplitCancel)
90
91
  }
@@ -13,7 +13,7 @@ const makeContext = (overrides = {}) => {
13
13
  on: jest.fn(),
14
14
  off: jest.fn(),
15
15
  isSnapEnabled: jest.fn(() => true),
16
- setGeometryValid: jest.fn(),
16
+ setCanFinish: jest.fn(),
17
17
  setDrawingPreviewProperty: jest.fn(),
18
18
  delete: jest.fn()
19
19
  }
@@ -47,7 +47,8 @@ describe('split', () => {
47
47
 
48
48
  split(context, 'poly')
49
49
 
50
- expect(typeof draw._geometryValidator).toBe('function')
50
+ expect(typeof draw._previewValidator).toBe('function')
51
+ expect(typeof draw._commitValidator).toBe('function')
51
52
  expect(draw.setSnapLayers).toHaveBeenCalledWith(['stroke-inactive.cold'])
52
53
  expect(dispatch).toHaveBeenCalledWith({ type: 'SET_HAS_SNAP_LAYERS', payload: true })
53
54
  expect(draw.changeMode).toHaveBeenCalledWith('draw_line', expect.objectContaining({
@@ -72,12 +73,14 @@ describe('split', () => {
72
73
  expect(draw.setSnapLayers).toHaveBeenCalledWith(['stroke-inactive.cold', 'extra'])
73
74
  })
74
75
 
75
- test('finalising the line computes a valid split, emits the result, and restores the previous validator', () => {
76
+ test('finalising the line computes a valid split, emits the result, and restores the previous validators', () => {
76
77
  const { context, dispatch, draw, eventBus } = makeContext()
77
78
  const polygonFeature = { id: 'poly' }
78
79
  const featureCollection = { type: 'FeatureCollection' }
79
80
  const previousValidator = jest.fn()
80
- draw._geometryValidator = previousValidator
81
+ const previousPreviewValidator = jest.fn()
82
+ draw._commitValidator = previousValidator
83
+ draw._previewValidator = previousPreviewValidator
81
84
  draw.get.mockReturnValue(polygonFeature)
82
85
  splitPolygon.mockReturnValue(featureCollection)
83
86
 
@@ -91,7 +94,8 @@ describe('split', () => {
91
94
  expect(splitPolygon).toHaveBeenCalledWith(polygonFeature, geojson)
92
95
  expect(dispatch).toHaveBeenCalledWith({ type: 'SET_ACTION', payload: { name: 'split', isValid: true } })
93
96
  expect(eventBus.emit).toHaveBeenCalledWith('draw:split', { originalFeatureId: 'poly', featureCollection })
94
- expect(draw._geometryValidator).toBe(previousValidator)
97
+ expect(draw._commitValidator).toBe(previousValidator)
98
+ expect(draw._previewValidator).toBe(previousPreviewValidator)
95
99
  // The splitter line only ever existed to compute the split — it must not
96
100
  // linger in the draw store afterwards.
97
101
  expect(draw.delete).toHaveBeenCalledWith('_splitter')
@@ -100,7 +104,7 @@ describe('split', () => {
100
104
  test('cancelling the splitter line stops listening and restores the previous validator', () => {
101
105
  const { context, draw } = makeContext()
102
106
  const previousValidator = jest.fn()
103
- draw._geometryValidator = previousValidator
107
+ draw._commitValidator = previousValidator
104
108
 
105
109
  split(context, 'poly')
106
110
  const onCancel = handlerFor(draw, 'cancel')
@@ -109,7 +113,7 @@ describe('split', () => {
109
113
  expect(draw.off).toHaveBeenCalledWith('create', expect.any(Function))
110
114
  expect(draw.off).toHaveBeenCalledWith('cancel', onCancel)
111
115
  expect(splitPolygon).not.toHaveBeenCalled()
112
- expect(draw._geometryValidator).toBe(previousValidator)
116
+ expect(draw._commitValidator).toBe(previousValidator)
113
117
  })
114
118
 
115
119
  test('finalising the line computes an invalid split and does not emit', () => {
@@ -124,13 +128,13 @@ describe('split', () => {
124
128
  expect(draw.delete).toHaveBeenCalledWith('_splitter')
125
129
  })
126
130
 
127
- describe('the installed draw._geometryValidator', () => {
131
+ describe('the installed validators', () => {
128
132
  test('never blocks a hard placement veto (phase: place)', () => {
129
133
  const { context, dispatch, draw } = makeContext()
130
134
  split(context, 'poly')
131
135
  dispatch.mockClear()
132
136
 
133
- const result = draw._geometryValidator({ feature: lineFeature([[0, 0], [1, 1]]), phase: 'place', mode: 'draw_line', vertexIndex: 1 })
137
+ const result = draw._previewValidator({ feature: lineFeature([[0, 0], [1, 1]]), phase: 'place', mode: 'draw_line', vertexIndex: 1 })
134
138
 
135
139
  expect(result).toEqual({ valid: true })
136
140
  expect(splitPolygon).not.toHaveBeenCalled()
@@ -143,7 +147,7 @@ describe('split', () => {
143
147
  split(context, 'poly')
144
148
  dispatch.mockClear()
145
149
 
146
- const result = draw._geometryValidator({ feature: lineFeature([[0, 0], [1, 1]]), phase: 'create', mode: 'draw_line' })
150
+ const result = draw._commitValidator({ feature: lineFeature([[0, 0], [1, 1]]), phase: 'create', mode: 'draw_line' })
147
151
 
148
152
  expect(result).toEqual({ valid: true })
149
153
  expect(splitPolygon).not.toHaveBeenCalled()
@@ -162,39 +166,50 @@ describe('split', () => {
162
166
  // gates the built-in rules by numVertices, not a caller's own rule, so this
163
167
  // must still reach the validator (numVertices: 1, below MIN_VERTICES.LineString).
164
168
  const feature = lineFeature([[0, 0], [1, 1]])
165
- const result = draw._geometryValidator({ feature, phase: 'preview', mode: 'draw_line', numVertices: 1 })
169
+ const result = draw._previewValidator({ feature, phase: 'preview', mode: 'draw_line', numVertices: 1 })
166
170
 
167
171
  expect(splitPolygon).toHaveBeenCalledWith(polygonFeature, { id: '_splitter', geometry: feature.geometry })
168
172
  expect(draw.setDrawingPreviewProperty).toHaveBeenCalledWith('splitter', 'valid')
169
- // Committed Done-gating (pluginState.geometryValid / map._drawGeometryValid) must only
173
+ // Committed Done-gating (pluginState.geometryValid / map._drawCanFinish) must only
170
174
  // change on an actual commit — otherwise a live "what if you added a point here" check
171
175
  // could flicker a just-committed valid split back to disabled.
172
176
  expect(dispatch).not.toHaveBeenCalled()
173
- expect(draw.setGeometryValid).not.toHaveBeenCalled()
177
+ expect(draw.setCanFinish).not.toHaveBeenCalled()
174
178
  expect(result).toEqual({ valid: true })
175
179
  })
176
180
 
177
- test('a committed vertex (phase: commit-add) updates both the visual colour and Done-gating', () => {
181
+ test('a committed vertex (phase: change) updates the visual colour and returns the verdict that gates Done', () => {
178
182
  const { context, dispatch, draw } = makeContext()
179
183
  splitPolygon.mockReturnValue(null)
180
184
  split(context, 'poly')
181
185
 
182
186
  const feature = lineFeature([[0, 0], [1, 1]])
183
- const result = draw._geometryValidator({ feature, phase: 'commit-add', mode: 'draw_line', vertexIndex: 1 })
187
+ const result = draw._commitValidator({ feature, phase: 'change', mode: 'draw_line', vertexIndex: 1 })
184
188
 
185
189
  expect(draw.setDrawingPreviewProperty).toHaveBeenCalledWith('splitter', 'invalid')
186
190
  expect(dispatch).toHaveBeenCalledWith({ type: 'SET_ACTION', payload: { name: 'split', isValid: false } })
187
- expect(dispatch).toHaveBeenCalledWith({ type: 'SET_GEOMETRY_VALID', payload: false })
188
- expect(draw.setGeometryValid).toHaveBeenCalledWith(false)
191
+ // The Done gate is applied by events.js from the returned verdict, not written here
192
+ expect(dispatch).not.toHaveBeenCalledWith(expect.objectContaining({ type: 'SET_VALIDATION_STATUS' }))
193
+ expect(draw.setCanFinish).not.toHaveBeenCalled()
189
194
  expect(result).toEqual({ valid: false, reason: expect.any(String) })
190
195
  })
191
196
 
197
+ test('the commit validator ignores the live preview phase', () => {
198
+ const { context, draw } = makeContext()
199
+ split(context, 'poly')
200
+
201
+ const result = draw._commitValidator({ feature: lineFeature([[0, 0], [1, 1]]), phase: 'preview', mode: 'draw_line' })
202
+
203
+ expect(result).toEqual({ valid: true })
204
+ expect(splitPolygon).not.toHaveBeenCalled()
205
+ })
206
+
192
207
  test('a line with fewer than two coordinates is treated as invalid without calling splitPolygon', () => {
193
208
  const { context, draw } = makeContext()
194
209
  split(context, 'poly')
195
210
 
196
211
  const feature = lineFeature([[0, 0]])
197
- const result = draw._geometryValidator({ feature, phase: 'preview', mode: 'draw_line', numVertices: 0 })
212
+ const result = draw._previewValidator({ feature, phase: 'preview', mode: 'draw_line', numVertices: 0 })
198
213
 
199
214
  expect(splitPolygon).not.toHaveBeenCalled()
200
215
  expect(draw.setDrawingPreviewProperty).toHaveBeenCalledWith('splitter', 'invalid')
@@ -6,23 +6,33 @@
6
6
  * All MapLibre / OL specifics live in the adapter.
7
7
  */
8
8
  import { ADAPTER_EVENTS } from './adapterEvents.js'
9
- import { validateGeometry } from './validation/validateGeometry.js'
9
+ import { getCommitChecks, isSameGeometry } from './validation/commitChecks.js'
10
10
  import { MIN_VERTICES_REASONS } from './validation/rules.js'
11
- import { MAP_SIZE_SCALES } from './defaults.js'
12
11
  import { stripInternalProperties } from './utils/stripInternalProperties.js'
12
+ import { isEditMode, isCheckedMode } from './utils/drawModes.js'
13
13
 
14
14
  const EDIT_VERTEX_MODE = 'edit_vertex'
15
15
  const GEOMETRY_INVALID_EVENT = 'draw:geometryinvalid'
16
+ const CREATED_EVENT = 'draw:created'
16
17
 
17
- // edit_point behaves like edit_vertex for the two checks below (restore-on-cancel, live
18
- // invalid-stroke gating) — a relocate session, just with one coordinate instead of a ring.
19
- // enterEditVertexMode (below) stays edit_vertex-only — it's only ever reached for a shape
20
- // that finished invalid, and Point geometry has no such failure mode (see rules.js).
21
- const EDIT_MODES = new Set([EDIT_VERTEX_MODE, 'edit_point'])
18
+ // A shape that finished without a passing check is reopened in edit mode, and its
19
+ // eventual edit-finish must report as a creation. Kept per draw adapter, not in
20
+ // createHandlers, which is rebuilt on every plugin state change.
21
+ const pendingCreateIds = new WeakMap()
22
+
23
+ // While editing, Done pressed during a pending check waits for that check (by revision): the
24
+ // edit finishes if it passes, and stays open if it fails or the shape changes again. Kept
25
+ // apart from a held new shape, which a new session discards — an edited feature must stay.
26
+ const editFinishRevisions = new WeakMap()
27
+
28
+ // A result can ask for the shape to be checked again once it's finished (recheckOnFinish),
29
+ // e.g. when the consumer skips its own check while drawing. Ignored on that finishing check.
30
+ const FINISH_PHASES = new Set(['create', 'edit-finish'])
31
+ const wantsRecheckOnFinish = ({ result, context }) => !!result?.recheckOnFinish && !FINISH_PHASES.has(context?.phase)
22
32
 
23
33
  // A shape that simply hasn't reached its minimum vertex count yet isn't a mistake —
24
34
  // it's the normal, expected state of "still being drawn" — so it's excluded below
25
- // even though it's a genuine SOFT_RULES failure like any other.
35
+ // even though it's a genuine COMMIT_RULES failure like any other.
26
36
  const isIncompleteShape = (reason) => Object.values(MIN_VERTICES_REASONS).includes(reason)
27
37
 
28
38
  // A discrete, one-shot invalid result (a rejected placement, a finished-but-invalid
@@ -31,9 +41,10 @@ const isIncompleteShape = (reason) => Object.values(MIN_VERTICES_REASONS).includ
31
41
  // alongside the existing public event, so the reason is visible without every
32
42
  // consumer having to wire up their own listener for it. The public event still
33
43
  // fires either way — only the hint is skipped for an incomplete shape.
34
- const createGeometryInvalidEmitter = (eventBus, hints) => (payload) => {
44
+ // A result with its own `announcement` is presented by the consumer, so it gets no hint.
45
+ const createGeometryInvalidEmitter = (eventBus, hints) => ({ announcement, ...payload }) => {
35
46
  eventBus.emit(GEOMETRY_INVALID_EVENT, payload)
36
- if (payload.reason && !isIncompleteShape(payload.reason)) { hints.show(payload.reason) }
47
+ if (!announcement && payload.reason && !isIncompleteShape(payload.reason)) { hints.show(payload.reason) }
37
48
  }
38
49
 
39
50
  // Claims MapControls' D-pad for the currently selected vertex — see the generic
@@ -58,44 +69,236 @@ const createVertexSelectionHandlers = ({ draw, pluginState, mapProvider, eventBu
58
69
  }
59
70
  })
60
71
 
61
- // Re-open a feature in vertex-edit mode (used when a drawn shape finishes invalid).
62
- // Mirrors the options built by api/editFeature.js. Edit-mode Done is gated by the
63
- // same validity, so the shape can't be finished until it's fixed.
64
- const enterEditVertexMode = ({ draw, appState, appConfig, mapState, dispatch }, featureId) => {
65
- draw.changeMode(EDIT_VERTEX_MODE, {
72
+ // Re-open a feature in edit mode (used when a drawn shape finishes and its check is
73
+ // invalid or errored). Mirrors the options built by api/editFeature.js. Edit-mode Done is
74
+ // gated by the same check, so the shape can't be finished until it passes.
75
+ // Emits draw:reopened so a consumer knows to show the shape's issues.
76
+ const enterEditMode = ({ draw, appState, appConfig, mapState, dispatch, eventBus }, featureId, geometryType) => {
77
+ const mode = geometryType === 'Point' ? 'edit_point' : EDIT_VERTEX_MODE
78
+ draw.changeMode(mode, {
66
79
  container: appState?.layoutRefs?.viewportRef?.current,
67
80
  deleteVertexButtonId: `${appConfig?.id}-draw-delete-point`,
68
81
  undoButtonId: `${appConfig?.id}-draw-undo`,
69
82
  isPanEnabled: appState?.interfaceType !== 'keyboard',
70
83
  interfaceType: appState?.interfaceType,
71
- scale: MAP_SIZE_SCALES[mapState?.mapSize],
84
+ scale: mapState?.mapSizeScale,
72
85
  featureId,
73
86
  getSnapEnabled: () => draw.isSnapEnabled()
74
87
  })
75
88
  const editing = draw.get(featureId)
89
+ const { status, result } = getCommitChecks(draw).state
76
90
  dispatch({ type: 'SET_FEATURE', payload: { feature: editing, tempFeature: editing } })
77
- dispatch({ type: 'SET_MODE', payload: EDIT_VERTEX_MODE })
78
- dispatch({ type: 'SET_GEOMETRY_VALID', payload: false })
79
- draw.setGeometryValid?.(false)
80
- draw.setInvalid?.(true)
91
+ dispatch({ type: 'SET_MODE', payload: mode })
92
+ dispatch({ type: 'SET_VALIDATION_STATUS', payload: status })
93
+ draw.setCanFinish?.(status === 'valid' || status === 'pending')
94
+ draw.setInvalid?.(status === 'invalid')
95
+ eventBus.emit('draw:reopened', { feature: stripInternalProperties(editing), status, reason: result?.reason ?? null })
96
+ }
97
+
98
+ // Screen reader messages for a slow check (see SLOW_CHECK_MS). A check that settles quickly
99
+ // says nothing new — Done enabling, or the hint for a failure, is enough. A result's own
100
+ // `announcement` replaces these, however quickly it settles.
101
+ const CHECK_MESSAGES = {
102
+ pending: 'Checking shape',
103
+ valid: 'Shape check passed',
104
+ invalid: 'Shape check failed',
105
+ error: 'Shape could not be checked'
106
+ }
107
+
108
+ // Announced as an 'action' so a run of quick changes collapses to the latest message,
109
+ // and so the failure hint's own ambient announcement yields rather than repeating it.
110
+ const announceCheck = (announce, { status, result, slow, afterPending }) => {
111
+ if (result?.announcement) {
112
+ announce?.(result.announcement, 'action')
113
+ } else if (status === 'pending') {
114
+ if (slow) { announce?.(CHECK_MESSAGES.pending, 'action') }
115
+ } else if (afterPending) {
116
+ announce?.((status === 'invalid' && result.reason) || CHECK_MESSAGES[status], 'action')
117
+ } else {
118
+ // Settled straight away
119
+ }
120
+ }
121
+
122
+ // Applies each settled commit-level check (validation/commitChecks.js). Only the
123
+ // latest revision ever reaches here, so a stale reply can't change the Done gate.
124
+ const createCheckStateHandler = ({ draw, dispatch, emitGeometryInvalid, announce }) => (state) => {
125
+ const { status, result, context, feature } = state
126
+ const valid = status === 'valid'
127
+ // A slow check is the same pending check, now shown as "Checking…"
128
+ dispatch(state.slow ? { type: 'SET_CHECK_SLOW' } : { type: 'SET_VALIDATION_STATUS', payload: status })
129
+ announceCheck(announce, state)
130
+ // Also blocks the adapters' finish gestures (double-click, clicking the first vertex)
131
+ // while the check is failing. A shape finished while its check is pending is held
132
+ // until it settles (see createFinishHandlers).
133
+ draw.setCanFinish?.(valid || status === 'pending')
134
+ if (status === 'pending' || status === 'error') { return }
135
+ // The invalid stroke is committed-validity-driven in edit mode only; in draw mode the
136
+ // adapters drive it live from the displayed geometry (placed vertices + cursor).
137
+ if (isEditMode(draw.getMode())) {
138
+ draw.setInvalid?.(!valid)
139
+ }
140
+ // edit-start is the baseline check on opening a feature, not a change the user made
141
+ if (!valid && context?.phase !== 'edit-start') {
142
+ const { reason, source, announcement } = result
143
+ emitGeometryInvalid({ reason, source, announcement, ...context, feature: stripInternalProperties(feature) })
144
+ }
145
+ }
146
+
147
+ // Finishing a new shape: created when its check passes, otherwise reopened in edit mode.
148
+ // A shape finished while its check is pending is held until it settles, with Done reading
149
+ // "Checking…" — for a point, Done shows just for that.
150
+ function createFinishHandlers ({ appState, appConfig, mapState, draw, dispatch, eventBus, resetState }) {
151
+ const checks = getCommitChecks(draw)
152
+
153
+ const create = (f) => {
154
+ resetState()
155
+ setTimeout(() => draw.changeMode('disabled'), 0)
156
+ eventBus.emit(CREATED_EVENT, stripInternalProperties(f))
157
+ }
158
+
159
+ const reopen = (featureId, geometryType) => {
160
+ pendingCreateIds.set(draw, featureId)
161
+ setTimeout(() => enterEditMode({ draw, appState, appConfig, mapState, dispatch, eventBus }, featureId, geometryType), 0)
162
+ }
163
+
164
+ // The map leaves draw mode; Done stays, disabled and reading "Checking…" once the check is slow
165
+ const hold = (featureId) => {
166
+ checks.hold(featureId)
167
+ dispatch({ type: 'SET_HOLDING', payload: true })
168
+ setTimeout(() => draw.changeMode('disabled'), 0)
169
+ }
170
+
171
+ // A shape can be finished by the Done button OR a map gesture (double-click, clicking
172
+ // the first vertex, Enter), so the latest check is re-applied here — a shape without a
173
+ // passing check must never be finalised. A passing or still-pending result for this
174
+ // same geometry is reused, so finishing doesn't repeat a server call; otherwise (a
175
+ // point, which has no commits before it's created, a failed result, or a result asking
176
+ // for recheckOnFinish) the shape is checked now with phase 'create'.
177
+ const checkFinished = (f) => {
178
+ const { status, feature: checkedFeature } = checks.state
179
+ const isReusable = (status === 'valid' || status === 'pending') && isSameGeometry(checkedFeature, f) && !wantsRecheckOnFinish(checks.state)
180
+ if (!isReusable) {
181
+ checks.run({ feature: f, context: { phase: 'create', mode: draw.getMode() }, onGeometryChange: draw._commitValidator })
182
+ }
183
+ return checks.state
184
+ }
185
+
186
+ const finish = (f) => {
187
+ const state = checkFinished(f)
188
+ if (state.status === 'valid') {
189
+ create(f)
190
+ } else if (state.status === 'pending') {
191
+ hold(f.id)
192
+ } else {
193
+ reopen(f.id, f.geometry?.type)
194
+ }
195
+ }
196
+
197
+ return {
198
+ onCreate: finish,
199
+ // A held shape is created once its check passes, or reopened in edit mode. A result that
200
+ // asks for recheckOnFinish, unknown until the pending check settled, is checked again.
201
+ onCheckSettled: (state) => {
202
+ const heldId = checks.heldId
203
+ if (heldId === undefined || state.status === 'pending') { return }
204
+ checks.release()
205
+ const finished = draw.get(heldId)
206
+ if (wantsRecheckOnFinish(state)) {
207
+ finish(finished)
208
+ } else if (state.status === 'valid') {
209
+ create(finished)
210
+ } else {
211
+ reopen(heldId, finished?.geometry?.type)
212
+ }
213
+ },
214
+ onEditFinish: (f) => {
215
+ resetState()
216
+ setTimeout(() => draw.changeMode('disabled'), 0)
217
+ // A shape that was drawn-then-fixed reports as a creation, not an edit.
218
+ if (pendingCreateIds.get(draw) === f.id) {
219
+ pendingCreateIds.delete(draw)
220
+ eventBus.emit(CREATED_EVENT, stripInternalProperties(f))
221
+ } else {
222
+ eventBus.emit('draw:edited', stripInternalProperties(f))
223
+ }
224
+ }
225
+ }
81
226
  }
82
227
 
83
- function createHandlers ({ appState, appConfig, mapState, pluginState, mapProvider, eventBus, hints, resetState }) {
228
+ // Done, and finishing an edit: pressed while editing with a check pending, Done waits for
229
+ // that check (see editFinishRevisions above) instead of finishing straight away. A result
230
+ // that asks for recheckOnFinish is checked again first, with phase 'edit-finish'.
231
+ function createEditFinishHandlers ({ draw, dispatch }) {
232
+ const checks = getCommitChecks(draw)
233
+
234
+ const waitFor = (revision) => {
235
+ editFinishRevisions.set(draw, revision)
236
+ dispatch({ type: 'SET_HOLDING', payload: true })
237
+ }
238
+
239
+ const finishEdit = (state) => {
240
+ if (state.status === 'pending') {
241
+ waitFor(state.revision)
242
+ return
243
+ }
244
+ if (!wantsRecheckOnFinish(state)) {
245
+ draw.done()
246
+ return
247
+ }
248
+ checks.run({ feature: state.feature, context: { phase: 'edit-finish', mode: draw.getMode() }, onGeometryChange: draw._commitValidator })
249
+ const next = checks.state
250
+ if (next.status === 'pending') {
251
+ waitFor(next.revision)
252
+ } else if (next.status === 'valid') {
253
+ draw.done()
254
+ } else {
255
+ dispatch({ type: 'SET_HOLDING', payload: false })
256
+ }
257
+ }
258
+
259
+ return {
260
+ handleDone: () => {
261
+ if (isEditMode(draw.getMode())) {
262
+ finishEdit(checks.state)
263
+ return
264
+ }
265
+ draw.done()
266
+ },
267
+ onEditCheckSettled: (state) => {
268
+ if (!editFinishRevisions.has(draw)) { return }
269
+ const isAwaitedCheck = editFinishRevisions.get(draw) === state.revision
270
+ if (isAwaitedCheck && state.status === 'pending') { return }
271
+ editFinishRevisions.delete(draw)
272
+ if (isAwaitedCheck && state.status === 'valid') {
273
+ finishEdit(state)
274
+ return
275
+ }
276
+ dispatch({ type: 'SET_HOLDING', payload: false })
277
+ }
278
+ }
279
+ }
280
+
281
+ function createHandlers ({ appState, appConfig, mapState, pluginState, mapProvider, eventBus, emitGeometryInvalid, announce, resetState }) {
84
282
  const { draw } = mapProvider
85
- const emitGeometryInvalid = createGeometryInvalidEmitter(eventBus, hints)
86
283
  const { feature, tempFeature } = pluginState
87
284
  const { dispatch } = pluginState
88
- // A shape that finished invalid and was re-opened in edit mode: its eventual
89
- // edit-finish must report as a creation, not an edit.
90
- let pendingCreateId = null
285
+ const checks = getCommitChecks(draw)
91
286
 
92
287
  return {
93
- handleDone: () => { draw.done() },
288
+ ...createEditFinishHandlers({ draw, dispatch }),
94
289
  handleCancel: () => {
95
290
  const mode = draw.getMode()
96
- if (EDIT_MODES.has(mode) && tempFeature?.id) { draw.add(feature) }
97
- pendingCreateId = null
98
- draw.cancel(); resetState()
291
+ const isEditing = isEditMode(mode) && !!tempFeature?.id
292
+ const isReopened = isEditing && pendingCreateIds.get(draw) === tempFeature.id
293
+ // A new shape that's finished but not yet created (held, or reopened for fixing) has
294
+ // no earlier version to restore, so it's discarded
295
+ const unfinishedId = checks.heldId ?? (isReopened ? tempFeature.id : undefined)
296
+ if (isEditing && !isReopened) { draw.add(feature) }
297
+ pendingCreateIds.delete(draw)
298
+ checks.release()
299
+ draw.cancel()
300
+ if (unfinishedId !== undefined) { draw.delete(unfinishedId) }
301
+ resetState()
99
302
  eventBus.emit('draw:cancelled', stripInternalProperties(feature))
100
303
  },
101
304
  handleUndo: () => draw.undo(),
@@ -104,68 +307,41 @@ function createHandlers ({ appState, appConfig, mapState, pluginState, mapProvid
104
307
  pluginState.dispatch({ type: 'TOGGLE_SNAP' })
105
308
  draw.setSnapEnabled(!pluginState.snap)
106
309
  },
107
- onCreate: (f) => {
108
- // A shape can be finished by the Done button OR a map gesture (double-click,
109
- // clicking the first vertex, Enter). Only the button is gated, so re-validate
110
- // here to catch the gesture paths — an invalid shape must never be finalised.
111
- const { valid, reason } = validateGeometry(f, { phase: 'create', mode: draw.getMode() }, { onGeometryChange: draw._geometryValidator })
112
- if (!valid) {
113
- pendingCreateId = f.id
114
- emitGeometryInvalid({ feature: stripInternalProperties(f), reason, phase: 'create', mode: EDIT_VERTEX_MODE })
115
- setTimeout(() => enterEditVertexMode({ draw, appState, appConfig, mapState, dispatch }, f.id), 0)
116
- return
117
- }
118
- resetState(); setTimeout(() => draw.changeMode('disabled'), 0); eventBus.emit('draw:created', stripInternalProperties(f))
119
- },
120
- onEditFinish: (f) => {
121
- resetState()
122
- setTimeout(() => draw.changeMode('disabled'), 0)
123
- // A shape that was drawn-then-fixed reports as a creation, not an edit.
124
- if (pendingCreateId && f.id === pendingCreateId) {
125
- pendingCreateId = null
126
- eventBus.emit('draw:created', stripInternalProperties(f))
127
- } else {
128
- eventBus.emit('draw:edited', stripInternalProperties(f))
129
- }
130
- },
131
- onCancel: () => {},
310
+ onCancel: () => { checks.reset() },
311
+ ...createFinishHandlers({ appState, appConfig, mapState, draw, dispatch, eventBus, resetState }),
132
312
  ...createVertexSelectionHandlers({ draw, pluginState, mapProvider, eventBus }),
133
313
  onUndoChange: (l) => { pluginState.dispatch({ type: 'SET_UNDO_STACK_LENGTH', payload: l }) },
134
314
  onUpdate: (f) => { eventBus.emit('draw:updated', stripInternalProperties(f)) },
135
315
  onGeometryChange: (e) => {
136
- // Only commit-level changes (commit-add/move/insert/delete) carry a `phase`.
316
+ // Only commit-level changes carry a `phase` ('change').
137
317
  // Preview events (e.g. split's live preview) have none and are ignored.
138
318
  if (!e?.phase) { return }
139
319
 
320
+ // A commit that lands after the session has ended (the adapters defer them a tick)
321
+ // is dropped rather than calling onGeometryChange.
140
322
  const mode = draw.getMode()
141
- const context = { phase: e.phase, vertexIndex: e.vertexIndex, mode }
142
- const { valid, reason } = validateGeometry(e.feature, context, { onGeometryChange: draw._geometryValidator })
323
+ if (!isCheckedMode(mode)) { return }
143
324
 
144
325
  // Rules only gate the Done button — never revert. A shape can pass through
145
- // interim invalid states while being built or reshaped.
146
- pluginState.dispatch({ type: 'SET_GEOMETRY_VALID', payload: valid })
147
- draw.setGeometryValid?.(valid)
148
- // The invalid stroke is committed-validity-driven in edit mode only; in draw
149
- // mode the adapters drive it live from the displayed geometry (placed
150
- // vertices + cursor) on every rubber-band move.
151
- if (EDIT_MODES.has(mode)) {
152
- draw.setInvalid?.(!valid)
153
- }
154
- if (!valid) {
155
- emitGeometryInvalid({ reason, ...context, feature: stripInternalProperties(e.feature) })
156
- }
326
+ // interim invalid states while being built or reshaped. The result is applied
327
+ // by the check-state handler once it settles.
328
+ checks.run({
329
+ feature: e.feature,
330
+ context: { phase: e.phase, vertexIndex: e.vertexIndex, mode },
331
+ onGeometryChange: draw._commitValidator
332
+ })
157
333
  },
158
- // A vertex placement was rejected (hard rule or user callback veto). Surface it
334
+ // A vertex placement was rejected (placement rule or user callback veto). Surface it
159
335
  // on the public bus with phase 'place', and as a hint toast, so the reason is visible.
160
336
  onPlacementBlocked: (e) => {
337
+ if (e.announcement) { announce?.(e.announcement, 'action') }
161
338
  emitGeometryInvalid({ ...e, feature: stripInternalProperties(e.feature) })
162
339
  },
163
340
  // Live (mid-drag) validity flip while editing — the displayed shape is exactly
164
- // what Done finishes there, so it gates the Done button in real time. Emitted
165
- // by the adapters' edit wiring only, on flips only.
341
+ // what Done finishes there, so it gates the Done button in real time alongside
342
+ // the commit-level check. Emitted by the adapters' edit wiring only, on flips only.
166
343
  onValidityChange: (e) => {
167
- pluginState.dispatch({ type: 'SET_GEOMETRY_VALID', payload: e.valid })
168
- draw.setGeometryValid?.(e.valid)
344
+ pluginState.dispatch({ type: 'SET_PREVIEW_VALID', payload: e.valid })
169
345
  },
170
346
  // Live placement-veto flip while drawing — gates the Add point button so it
171
347
  // never looks active when a tap would be rejected.
@@ -228,7 +404,7 @@ function detachDrawEvents (draw, handlers) {
228
404
  draw.off(ADAPTER_EVENTS.INTERFACE_TYPE_CHANGE, handlers.onInterfaceTypeChange)
229
405
  }
230
406
 
231
- export function attachEvents ({ appState, appConfig, mapState, pluginState, mapProvider, buttonConfig, eventBus, hints }) {
407
+ export function attachEvents ({ appState, appConfig, mapState, pluginState, mapProvider, buttonConfig, eventBus, hints, announce }) {
232
408
  const { draw } = mapProvider
233
409
  const resetState = () => {
234
410
  pluginState.dispatch({ type: 'SET_MODE', payload: null })
@@ -236,9 +412,21 @@ export function attachEvents ({ appState, appConfig, mapState, pluginState, mapP
236
412
  // Release MapControls' D-pad back to panning the map whenever a draw/edit
237
413
  // session ends — a stale claim here would silently hijack it for good.
238
414
  mapProvider.activeMoveTarget = null
415
+ // Ends the check session too, so a reply still in flight is dropped, along with any
416
+ // Done that was waiting on it.
417
+ getCommitChecks(draw).reset()
418
+ editFinishRevisions.delete(draw)
239
419
  }
240
- const handlers = createHandlers({ appState, appConfig, mapState, pluginState, mapProvider, eventBus, hints, resetState })
420
+ const emitGeometryInvalid = createGeometryInvalidEmitter(eventBus, hints)
421
+ const handlers = createHandlers({ appState, appConfig, mapState, pluginState, mapProvider, eventBus, emitGeometryInvalid, announce, resetState })
422
+ const checks = getCommitChecks(draw)
423
+ const applyCheckState = createCheckStateHandler({ draw, dispatch: pluginState.dispatch, emitGeometryInvalid, announce })
424
+ checks.setOnSettle((state) => {
425
+ applyCheckState(state)
426
+ handlers.onCheckSettled(state)
427
+ handlers.onEditCheckSettled(state)
428
+ })
241
429
  attachButtonHandlers(buttonConfig, handlers)
242
430
  attachDrawEvents(draw, handlers)
243
- return () => { detachButtonHandlers(buttonConfig); detachDrawEvents(draw, handlers) }
431
+ return () => { checks.setOnSettle(null); detachButtonHandlers(buttonConfig); detachDrawEvents(draw, handlers) }
244
432
  }