File tree 1 file changed +17
-0
lines changed
apps/front-end/src/components/map
1 file changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -41,6 +41,11 @@ const openPopup = async (
41
41
popupClosedCallback : ( ) => void ,
42
42
offset ?: [ number , number ] ,
43
43
) => {
44
+ if ( popup ?. isOpen ( ) && popupIx === itemIx ) {
45
+ console . log ( `Popup for item @${ itemIx } already open` ) ;
46
+ return ;
47
+ }
48
+
44
49
console . log ( `Open popup for item @${ itemIx } ${ coordinates } ` ) ;
45
50
46
51
// Shift the popup up a bit so it doesn't cover the marker
@@ -250,6 +255,16 @@ export const createMap = (
250
255
const coordinates = feature . geometry . coordinates . slice ( ) ;
251
256
const itemIx = feature . properties ?. ix ;
252
257
258
+ if ( popup ?. isOpen ( ) && popupIx === itemIx ) {
259
+ console . log (
260
+ `Popup for item @${ itemIx } already open so toggle closed` ,
261
+ ) ;
262
+ popup ?. remove ( ) ;
263
+ popupIx = undefined ;
264
+ popup = undefined ;
265
+ return ;
266
+ }
267
+
253
268
// ease to a position so that the popup is fully visible
254
269
map
255
270
. easeTo ( {
@@ -339,6 +354,8 @@ export const createMap = (
339
354
// Remove previous popup - remove listener to prevent looping back and confusing React code
340
355
popup ?. off ( "close" , popupClosedCallback ) ;
341
356
popup ?. remove ( ) ;
357
+ popupIx = undefined ;
358
+ popup = undefined ;
342
359
flyToThenOpenPopupRecursive ( ) ;
343
360
} ) ;
344
361
You can’t perform that action at this time.
0 commit comments