diff --git a/packages/plugins/Gfi/CHANGELOG.md b/packages/plugins/Gfi/CHANGELOG.md index b8b9282b9..edd812f1b 100644 --- a/packages/plugins/Gfi/CHANGELOG.md +++ b/packages/plugins/Gfi/CHANGELOG.md @@ -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`. diff --git a/packages/plugins/Gfi/src/store/actions/setupMultiSelection.ts b/packages/plugins/Gfi/src/store/actions/setupMultiSelection.ts index 82e995253..3e978e712 100644 --- a/packages/plugins/Gfi/src/store/actions/setupMultiSelection.ts +++ b/packages/plugins/Gfi/src/store/actions/setupMultiSelection.ts @@ -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) { if (boxSelect || multiSelect === 'box' || multiSelect === 'circle') { if (boxSelect) { @@ -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: