Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: GvmInfoWindow components are not removed from the map #323

Closed
Tuhtarov opened this issue Apr 24, 2024 · 7 comments
Closed

Bug: GvmInfoWindow components are not removed from the map #323

Tuhtarov opened this issue Apr 24, 2024 · 7 comments
Assignees
Labels
bug Something isn't working fix released

Comments

@Tuhtarov
Copy link

Tuhtarov commented Apr 24, 2024

Describe the bug

GvmInfoWindow components are not deleted (not closed) in a vue template when the object responsible for rendering this component is deleted in a reactive variable.

To reproduce

For example, we have a display of 3 markers and 3 windows above them. After deleting any element from the storage, the marker and the window must be deleted from map. Currently, only the marker is deleted. But the window remains on the map.

Demo code roughly describing my component for displaying some data on a map:

<template>
  <GmvMap
      ref="gmvMap"
      map-id="DEMO_MAP_ID"
      :map-key="'MainMap'"
      style="width: 100%; height: 100%"
  >
     <template #visible>
          <div v-for="(marker) in markersStore.stack" :key="`k${marker.id}`">
              <GmvMarker
                :position="marker.position"
                :marker-key="`marker${marker.id}`"
                :map-key="'MainMap'"
              />
              
              <GmvInfoWindow
                :map-key="'MainMap'"
                :marker-key="`marker${marker.id}`"
                :info-window-key="`infoWindow${marker.id}`"
                :opened="true"
                :position="marker.position"
              >
                  <div class="pa-2" @click="popStack">
                      some content
                  </div>
            </GmvInfoWindow>
        </div>
     </template> 
  </GmvMap>
</template>

<script setup lang="ts">
// ...
// pinia store 
const markerStore = useMarkerStore()
const popStack = () => markerStore.stack.pop()
</script>

Expected behavior

The marker and window should be removed from the map if the element responsible for drawing the marker and window was deleted in the data source.

Current behavior

Only the marker is removed, the window remains.

Additional context

Using this crutch code, you can close these windows on the map

watch(
  () => markersStore.stack,
  (val) => {
    val.forEach((marker) => {
       useInfoWindowPromise(`infoWindow${marker.id}`).then((infoWindow) => infoWindow?.close())
    })
  },
  { deep: true },
)

Screenshots

image

Desktop

  • OS: windows 10
  • Browser chrome (123.0.6312.123)

Versions

  • Node: v20.11.1
  • NPM: 10.2.4
  • VUE: 3.4.21
  • VITE: 5.2.0

Package manager

  • NPM

Plugin version

  • 2.1.1
@Tuhtarov Tuhtarov added the bug Something isn't working label Apr 24, 2024
@diegoazh diegoazh self-assigned this Apr 24, 2024
Copy link

diegoazh added a commit that referenced this issue Apr 24, 2024
The inject key can only be used on descendants not in siblings. Composables on mounted hook are more accurate.

Solve: #323
@diegoazh diegoazh added the WIP work in progress label Apr 24, 2024
diegoazh added a commit that referenced this issue Apr 24, 2024
* fix(v3): change inject for composable to get component promise

The inject key can only be used on descendants not in siblings. Composables on mounted hook are more accurate.

Solve: #323

* test(v3): update cluster test to use the new key feature

* chore(root): update package-manager y package.json and gh workflows
@diegoazh diegoazh added the fix label Apr 24, 2024
github-actions bot pushed a commit that referenced this issue Apr 24, 2024
## [2.1.2](gmv3_v2.1.1...gmv3_v2.1.2) (2024-04-24)

### Bug Fixes

* **v3:** change inject for composable to get component promise  ([#324](#324)) ([6613c59](6613c59)), closes [#323](#323)
@diegoazh diegoazh added released and removed WIP work in progress labels Apr 24, 2024
@diegoazh
Copy link
Owner

@Tuhtarov thank you again. I found a logical issue here, and now it's working as expected. I'm closing the issues considering it solved, feel free to re-open it if needed or open a new one.

@Tuhtarov
Copy link
Author

And thank you again :)

@Tuhtarov
Copy link
Author

@diegoazh, hello again!
I tested it and found that the bug remained :(

@Tuhtarov
Copy link
Author

image

@diegoazh
Copy link
Owner

diegoazh commented Apr 25, 2024

Hi @Tuhtarov I checked and it works as expected, you can check it in this stackblitz example.

  1. click the marker on the first map
  2. an info window should be displayed
  3. after 3 seconds the marker is removed with a v-if and the info window is closed.

Please check the implementation on the HellowWorld component, I think your issue can be related to your implementation, let me know if you found something weird or new.

@Tuhtarov
Copy link
Author

Tuhtarov commented May 7, 2024

Hi @diegoazh, I appreciate your work and look forward to your response.
I made an example based on a project on stackblitz where you can clearly see that InfoWindow components are not deleted after they are removed from the data source. After clicking on the text in InfoWindow, check the log in the console. In theory, the marker and window should be deleted on the map together, but only the marker is deleted.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working fix released
Projects
None yet
Development

No branches or pull requests

2 participants