Repository navigation
This version provides compatibility with Leaflet 2.0.0-beta.4 while staying compatible with Leaflet 1.9, and modernizes the control's accessibility, input handling and styling.
Breaking changes
- The search icon and the throbber are drawn by a
::beforemask incurrentColorinstead of abackground-image. If you replaced the icon viabackground-image, hide the mask with.leaflet-control-geocoder-icon::before { display: none }(7ea66b8) - Results are
<li><span>instead of<li><a>, and the control is a<search>element instead of a<div>. Update custom CSS targeting.leaflet-control-geocoder-alternatives aordiv.leaflet-control-geocoder(82f5948) (2a04fd7) - The
errorMessageoption is inserted as text, not as HTML (396082f) - Result HTML (
htmlTemplate) is sanitized by the Sanitizer API where supported, which removes e.g.styleattributes and event handlers (c68f4ca) - The marker popup content is an element instead of a string (c68f4ca)
- The built-in geocoders reject with the new
HttpErroron HTTP error responses (8b43075) - Only the icon button toggles the control (or geocodes with
collapsed: false), not any press inside the control (236028b) - The input uses
font: inheritwith at least 16px, and the input and result widths are inrem(b6a328a)
Features
- Leaflet 2.0 compatibility: replace the removed
L.Browser.touch, typings compatible with Leaflet 2's bundled types; peer dependencyleaflet: ^1.6.0 || ^2.0.0-beta.4(40dd51a) (faef65d) - Abort superseded requests via
AbortController;GeocodingContext.signalis passed tofetchby the built-in geocoders (96f0ec3) (c83e9c7) - New
errorgeocodeanderrorsuggestevents (96f0ec3) - Accessibility:
- ARIA combobox pattern:
role=comboboxinput witharia-expandedandaria-activedescendant,role=listboxresults (82f5948) - label for the input (new
inputLabeloption),<search>landmark (2a04fd7) - focus management: expanding focuses the input, collapsing returns the focus to the icon (82f5948)
- "Nothing found" is announced via a
role=statuslive region (396082f) - keep the focus ring; mark the selected result with an outline, also in forced colors mode (ec5ff44)
- throbber animation slowed down for
prefers-reduced-motion(7ea66b8)
- ARIA combobox pattern:
- Theming via
--leaflet-control-geocoder-*CSS custom properties,color-scheme: light(b6a328a) - Mobile keyboards:
enterkeyhint=search, no autocorrect/autocapitalize/spellcheck (2a04fd7) - Right-to-left layouts via CSS logical properties (b6a328a)
Fixes
- The throbber kept spinning when geocoding failed; the error message is shown now (96f0ec3)
- With
collapsed: false, clicking the icon with a mouse did not geocode, and clicking into the input did (236028b) - With Leaflet 2, pressing into the input collapsed the control (236028b)
- The icon could not be toggled with the keyboard in the
touchandhoverexpand modes (236028b) - Enter while composing with an IME (Japanese, Chinese, Korean) started a search (6554269)
- Unset options such as API keys were sent as
key=undefined(8b43075) - Photon: suggestions dropped the map location bias (c83e9c7)
- Result HTML was re-serialized together with the result icon via
innerHTML +=(c68f4ca)
Development
- Run the tests against Leaflet 1.9 and 2.0, new specs for the control;
npm run typecheckagainst both Leaflet versions (44d0208) - Replace
conventional-changelog-cliwith a dependency-freenpm run changelogscript (84908eb) (67b840f) - Use CSS nesting (flattened in the build) (6e44b2b)
- Update
@types/leaflet1.9.22 (f46b90b),typedoc0.28.20 (5d48a82),happy-dom21.0.4 (59bb2e6),typescript6.0.3 (850d768),vite-plus1.6.0 (172120e)