Skip to content

Commit 86cb8a0

Browse files
committed
PB-1480: Also handle setSearchQuery on redoSearchWhenNeeded.
1 parent 8ef3c10 commit 86cb8a0

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

packages/mapviewer/src/store/modules/search.store.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ const actions = {
9898
// there are situations where we don't want to center on the features or coordinates searched.
9999
// for example: when we are sharing a position with a search query. In those situation, the
100100
// 'zoom to extent' should be avoided. We center by default.
101-
if (extractedCoordinate && shouldCenter) {
101+
if (extractedCoordinate && shouldCenter) {
102102
let coordinates = [...extractedCoordinate.coordinate]
103103
if (extractedCoordinate.coordinateSystem !== currentProjection) {
104104
// special case for LV03 input, we can't use proj4 to transform them into

packages/mapviewer/src/store/plugins/redo-search-when-needed.plugin.js

+8-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { SET_LANG_MUTATION_KEY } from '@/store/modules/i18n.store'
2+
import coordinateFromString from '@/utils/coordinates/coordinateExtractors'
23

34
/**
45
* Redo the search results on lang change if the search query is defined
@@ -8,11 +9,17 @@ import { SET_LANG_MUTATION_KEY } from '@/store/modules/i18n.store'
89
const redoSearchWhenNeeded = (store) => {
910
function redoSearch() {
1011
if (store.state.search.query.length > 2) {
12+
let shouldCenter = store.state.position.crossHair === null
13+
const extractedCoordinate = coordinateFromString(store.state.search.query)
14+
if (extractedCoordinate) {
15+
shouldCenter = true
16+
}
1117
store.dispatch('setSearchQuery', {
1218
query: store.state.search.query,
1319
// we don't center on the search query when redoing a search if there is a crosshair
14-
shouldCenter: store.state.position.crossHair === null,
20+
shouldCenter: shouldCenter,
1521
originUrlParam: true, // necessary to select the first result if there is only one else it will not be because this redo search is done every time the page loaded
22+
dispatcher: 'redoSearchWhenNeeded',
1623
})
1724
}
1825
}

0 commit comments

Comments
 (0)