Skip to content

Commit

Permalink
Merge pull request #233 from Dataport/fix/gfi-direct-select
Browse files Browse the repository at this point in the history
Adjust isDrawing so directSelect works even when multiSelect is used
  • Loading branch information
dopenguin authored Feb 13, 2025
2 parents 4c94de3 + 305112e commit 75600bc
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 9 deletions.
4 changes: 4 additions & 0 deletions packages/plugins/Gfi/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# CHANGELOG

## unpublished

- 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

- Breaking: Upgrade `@masterportal/masterportalapi` from `2.40.0` to `2.45.0` and subsequently `ol` from `^9.2.4` to `^10.3.1`.
Expand Down
23 changes: 14 additions & 9 deletions packages/plugins/Gfi/src/store/actions/setupMultiSelection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,14 @@ 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: {
gfiConfiguration: { boxSelect, directSelect, multiSelect },
},
rootGetters: { map },
rootGetters,
}: PolarActionContext<GfiState, GfiGetters>) {
if (boxSelect || multiSelect === 'box' || multiSelect === 'circle') {
if (boxSelect) {
Expand All @@ -66,22 +68,25 @@ 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
})
)
map.addInteraction(draw)
rootGetters.map.addInteraction(draw)
}
if (directSelect) {
map.on('click', ({ coordinate, originalEvent }) => {
if (!isDrawing(map)) {
rootGetters.map.on('click', ({ coordinate, originalEvent }) => {
if (!isDrawing(rootGetters.map)) {
dispatch('getFeatureInfo', {
coordinateOrExtent: coordinate,
modifierPressed:
Expand Down

0 comments on commit 75600bc

Please sign in to comment.