Skip to content

Commit

Permalink
Fix issue of _isMultiSelect not being cleaned up if a drawing is aborted
Browse files Browse the repository at this point in the history
A drawing is always aborted if a user only clicks into the map using
CTRL / Command.
  • Loading branch information
dopenguin committed Feb 13, 2025
1 parent fd96b38 commit e2ad6b1
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
3 changes: 1 addition & 2 deletions packages/plugins/Gfi/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@

## unpublished

- Fix: Adjust detection whether a user is drawing so that `directSelect` is not disabled when `multiSelect` is in use.
- Fix: Refactor setup-function for multi selection so that a user can (again) select and deselect features via `directSelect`.
- Fix: Clean-up internal flag used for `multiSelect` if a drawing is aborted. This is always the case if a user simply clicks into the map holding CTRL / Command.

## 3.0.0

Expand Down
20 changes: 13 additions & 7 deletions packages/plugins/Gfi/src/store/actions/setupMultiSelection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@ const isDrawing = (map: Map) =>
.getArray()
.some(
(interaction) =>
// @ts-expect-error | internal hack to detect it from @polar/plugin-draw
(interaction instanceof Draw && interaction._isDrawPlugin) ||
(interaction instanceof Draw &&
// @ts-expect-error | internal hack to detect it from @polar/plugin-gfi and @polar/plugin-draw
(interaction._isMultiSelect || interaction._isDrawPlugin)) ||
interaction instanceof Modify ||
// @ts-expect-error | internal hack to detect it from @polar/plugin-draw
interaction._isDeleteSelect ||
Expand All @@ -42,6 +43,8 @@ const drawOptions: DrawOptions = {
condition: () => false,
}

// NOTE: This disable can be removed once the deprecated parameter 'boxSelect' has been removed
// eslint-disable-next-line max-lines-per-function
export function setupMultiSelection({
dispatch,
getters: {
Expand All @@ -65,16 +68,19 @@ export function setupMultiSelection({
// @ts-expect-error | internal hack to detect it in @polar/plugin-pins
draw._isMultiSelect = true
})
draw.on('drawabort', () => {
// @ts-expect-error | internal hack to detect it in @polar/plugin-pins
draw._isMultiSelect = false
})
draw.on('drawend', (e) =>
dispatch('getFeatureInfo', {
// @ts-expect-error | A feature that is drawn has a geometry.
coordinateOrExtent: e.feature.getGeometry().getExtent(),
modifierPressed: true,
}).finally(
() =>
// @ts-expect-error | internal hack to detect it in @polar/plugin-pins
(draw._isMultiSelect = false)
)
}).finally(() => {
// @ts-expect-error | internal hack to detect it in @polar/plugin-pins
draw._isMultiSelect = false
})
)
rootGetters.map.addInteraction(draw)
}
Expand Down

0 comments on commit e2ad6b1

Please sign in to comment.