[3.1.0] Click on v-map fires MapMouseEvent and MouseEvent
jasonhibbs opened this issue · 6 comments
When listening for a click on the map, I’m expecting the event to be MapMouseEvent
, but MouseEvent
also fires, and typescript complains that I cannot assign one to the other.
To prevent the MouseEvent
from firing, I am stopping propagation on the originalEvent
, but this doesn’t solve my TS issue:
<v-map @click="onMapClick></v-map>
function onMapClick(e: MapMouseEvent) {
e.originalEvent.stopPropagation()
}
Does @click.stop
work for you?
From Vue docs on defineEmits
:
If a native event (e.g., click) is defined in the emits option, the listener will now only listen to component-emitted click events and no longer respond to native click events.
This won't solve the issue itself, but just trying to offer a workaround. What's the use case for the @click on v-map, and what's the secondary click used for?
Is it necessary in your use case to detect a top level click? (I'm assuming it likely is, to close a popup or similar?)
I have a workaround:
To prevent the MouseEvent from firing, I am stopping propagation on the originalEvent
This is possible because mapbox already provides the native event as originalEvent
in MapMouseEvent
– if I needed the native event, I’d expect to use this.
Use case for @click
is varied, but the expectation is that it would emit only the mapbox event: MapMouseEvent
.
My best guess is that VMap
isn’t using defineEmits
which would deregister the native event and behave as expected.
@vinayakkulkarni do you agree with my assessment?
My best guess is that VMap isn’t using defineEmits which would deregister the native event and behave as expected.