Hi I am looking a way to stopPropagation on click event after I click on my geocoder component inside mapbox. I try it this way but it is not working. Only one event type which I found works is .on('result' () => {...} ). Is there other way to achieve this ?? Thx.
const geocoder = new MapboxGeocoder({
accessToken: mapboxgl.accessToken,
mapboxgl: mapboxgl,
language: 'cs'
});
geocoder.on('click', (e: any) => {
console.log('click'); // This never happen
e.originalEvent.stopPropagation();
});
map.addControl(
geocoder
);
Edit:
Okay so map.addControl add new controls above map. It looks like this

There is problem with that becouse I created button on the right side which change colors and do some stuff when you click on it OR you click direct on map. But if you click on searchbar, this event fire also and action which should be fired only when you click direct on map or that button is called.
From https://github.com/mapbox/mapbox-gl-geocoder/blob/main/API.md#on, the events that the MapboxGeocoder listens for are clear, loading, results, result, error.
Can you say a little more about why you want to stop the on click event / what you are trying to achieve? That answer might suggestion options for implementation