maplibre / maplibre-gl-geocoder

Geocoding for MapLibre
ISC License
45 stars 17 forks source link

Form submission blocked by clear button #115

Closed daiwai closed 1 week ago

daiwai commented 2 months ago

When placing the Geocoder component inside a form, the form cannot be submitted using the Enter key. This issue arises because the clear button lacks a type="button" attribute, causing it to default to type="submit". Consequently, it is triggered during form submission and cancels the submission within the _clear function.

daiwai commented 2 months ago

A simple workaround is to set the attribute after adding the Geocoder control to the map (or another element).

container.querySelector('.maplibregl-ctrl-geocoder--button').setAttribute('type', 'button');