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

InfoWindow: closeclick does not get propagated #51

Closed
oliverkirsch opened this issue Feb 15, 2023 · 4 comments
Closed

InfoWindow: closeclick does not get propagated #51

oliverkirsch opened this issue Feb 15, 2023 · 4 comments
Assignees
Labels
bug Something isn't working help wanted You can contribute with this with in any way possible

Comments

@oliverkirsch
Copy link

oliverkirsch commented Feb 15, 2023

Hey everyone,

this is all quite new to me, so I might be completely mistaken, but it appears to me, that the infoWindow does not propagate its ("native" google maps) closeclick event properly.

I'm using vue-google-maps-community-fork in a quasar (2.11.5) environment which generally works. However I noticed that when clicking the "x" of an InfoWindow, this window disappears but my @closeclick method is not being triggered. No idea if that has something to do with my environment or if I'm missing anything else here.

I added the following line to the afterCreate() hook of infoWindow.vue:
this.$infoWindowObject.addListener('closeclick', () => { this.$emit('closeclick') })
which seems to help with this issue: Clicking the "x" now triggers my @closeclick.

There is a slight drawback however, my (parent component) method for @closeclick will unset the "opened" property of an InfoWindow, therefore the watcher will be triggered and _openInfoWindow() will emit a second "closeclick". Which isn't nice but better than before.

From my understanding the this.$emit('closeclick') in the _openInfoWindow() method does not make too much sense there anyway, at least when I expect this to trigger only when I actually clicked close and not also when I (externally) set my opened prop to false. But that may be as well me misunderstandingthe concept.

Can you confirm this behavior? Or, otherwise, do you have any hints what I might be doing wrong?

@oliverkirsch
Copy link
Author

oliverkirsch commented Feb 15, 2023

On a side note: Clicking the "x" still closes the InfoWindow. So you have to make sure, that your opened state gets false in your @closeclick method. I'm not sure if this can be prevented somehow. But my understanding would be:

  • opened actually holds the opened state of this InfoWindow. As long as it is true, the InfoWindow is being shown.
  • @closeclick triggers a method saying "I'd like to close this" which requires some code to actually unset the opened state

What I would expect can be done by further extending my addListener:

    this.$infoWindowObject.addListener('closeclick', () => { 
      this.$emit('closeclick')
      this.$infoWindowObject.open(this.$map, this.$markerObject)
    })

So while the InfoWindow itself is being closed, it is re-opened instantly. If the opened prop is being changed, this will actually close the InfoWindow (using the watcher/_openInfoWindow() method).

But I really don't know if I'm causing any more mess by this.

In case this somehow makes sense, I'd be happy to provide a PR.

@NathanAP
Copy link
Owner

NathanAP commented Feb 17, 2023

Hello! Sorry for being late ):

Thanks for reporting! You can try to open your PR and we could try to see if someone can help us testing it :)

Edit: in the worst case this can be a optional feature (or props) for those who want to keep it how it is now.

@NathanAP NathanAP self-assigned this Feb 17, 2023
@NathanAP NathanAP added bug Something isn't working help wanted You can contribute with this with in any way possible labels Feb 17, 2023
@oliverkirsch
Copy link
Author

Hi, no worries about the timing and thanks for the effort :)
I hope I did this correctly, but it seems, I created a PR.

Optional might be a good idea in case other projects rely on the current behavior.

@NathanAP
Copy link
Owner

#52 is now merged, I'm closing this one. If someone gets affected and wants to help us improve this situation let us know!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted You can contribute with this with in any way possible
Projects
None yet
Development

No branches or pull requests

2 participants