Files
editor/e2e
Grimace (奶昔大哥)andCodex 54f0ba140a feat: preview sprites in the icon-image picker (#2359)
## Description

Add a dedicated sprite autocomplete for literal `icon-image` values.
Each searchable option shows its thumbnail and name, and selection keeps
the original sprite ID in the style. Keyboard selection and free-form
text remain available; expressions continue to use the existing
expression editor. Pattern fields keep their existing inputs.

The preview uses atlas bounds and pixel ratios. SDF sprites are decoded
into neutral black silhouettes using MapLibre's distance-field contour,
rather than displaying the distance bitmap. This is a catalog preview,
not a rendering of the layer's data/zoom-dependent paint or halos.
Sprite arrays retain MapLibre namespaces, and URL query parameters
remain after the JSON/PNG extension.

Metadata responses from a previous style are ignored after the sprite
source changes. Missing atlas images leave the names usable. The menu
opens above the field when there is not enough space below it.

Fixes #1294. Implements the scope proposed in the issue and welcomed by
CommanderStorm; follows #1792's request for a separate sprite input with
images in the option rows. No new dependencies or changes to the generic
`InputAutocomplete` component.

## Visuals

| Before | After |
| --- | --- |
| ![Text-only sprite
menu](https://raw.githubusercontent.com/jjohnnystwsss/maputnik/d368f3509fbb7c308ecdce6c97701af982bff14c/before.png)
| ![Sprite menu with
thumbnails](https://raw.githubusercontent.com/jjohnnystwsss/maputnik/d368f3509fbb7c308ecdce6c97701af982bff14c/after.png)
|

SDF preview beside the actual MapLibre render of the selected fixture:

![SDF preview and map
rendering](https://raw.githubusercontent.com/jjohnnystwsss/maputnik/d368f3509fbb7c308ecdce6c97701af982bff14c/after-sdf.png)

[Isolated screenshots and
provenance](https://github.com/jjohnnystwsss/maputnik/tree/d368f3509fbb7c308ecdce6c97701af982bff14c)
(not part of the feature diff).

## Verification

- Five new pure-logic tests cover URL handling, metadata
namespaces/bounds, empty sources and SDF alpha conversion; all 55 unit
tests pass.
- Fifteen new driver-based browser cases cover actual option pixels,
search, mouse/keyboard selection, viewport placement, persisted style
values, expression editing, sprite replacement/removal, namespaces,
broken images and delayed old responses.
- On the untouched base, the thumbnail assertion fails while all four
text options are present.
- Deliberately changing the expected thumbnail color fails; disabling
the stale-response guard also fails. Both mutations were reverted.
- Full official `npm test -- --workers 2`: all 199 cases pass (184
existing + 15 new). Lint, SCSS lint and type-checked production build:
passed.

Small sprite fixtures were authored for this change and carry the
repository's MIT license. No external tile, sprite or paid service is
required by the new cases.

Codex assisted with the design, implementation and tests; the preview
and actual map output were inspected locally.

## Launch Checklist

- [x] Briefly describe the changes in this PR.
- [x] Link to related issues.
- [x] Include before/after visuals or gifs if this PR includes visual
changes.
- [x] Write tests for all new functionality.
- [x] Add an entry to `CHANGELOG.md` under the `## main` section.

Co-authored-by: Codex <noreply@openai.com>
2026-11-24 10:07:05 +02:00
..
2026-07-12 15:46:30 +03:00