# fix: improve previews for small sprites
## Description
Small sprites appeared at their original display size in the sprite
picker, making them difficult to recognize when choosing an icon or
pattern.
- Render previews in a fixed 36 × 36 CSS pixel canvas. Scale and center
each sprite while preserving its aspect ratio.
- Prefer matching `@2x.json` metadata and `@2x.png` atlas for previews.
Use the base atlas when `@2x` metadata is unavailable.
- Size the canvas backing store for the display's device pixel ratio.
Preserve query strings and fragments when building sprite URLs.
Follow-up to [#2364](https://github.com/maplibre/maputnik/pull/2364),
which extended sprite previews to all sprite-backed fields as part of
[#1294](https://github.com/maplibre/maputnik/issues/1294).
## Visuals
### Before
Small sprites appear at their original display size in the picker.

### After
The same sprites are scaled to fit the fixed-size preview using the
`@2x` atlas.

## Verification
All checks for this change passed.
- Playwright covers the `@2x` atlas, the centered 36 × 36 preview for a
small rectangular sprite, the 72 × 72 canvas at device pixel ratio 2,
and the base atlas fallback. Existing coverage exercises SDF, sprite
selection, image failures, and catalog updates.
- `npm run lint`
- `npm run lint-css`
- `npm run build`
- `npm run test-unit -- --run` (55 passed)
- `npm run test -- e2e/sprite-picker.spec.ts --workers=2` (21 passed)
- Confirmed that deliberately changing the expected CSS width, backing
canvas width, and fallback pixel color fails the corresponding tests.
Restored the correct assertions.
## 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: FantasticSPM <asd507172@gmail.com>
## 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 |
| --- | --- |
| 
| 
|
SDF preview beside the actual MapLibre render of the selected fixture:

[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>
Fixes#1548
The Debug modal only listed the map options for `mlgljs`, so an `mbgljs`
style got an empty "Options". It now checks `renderer !== "ol"`, as
suggested in the issue, which is how `App.tsx` picks the map anyway.
## 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.
Added an e2e case with a small `mbgljs` fixture.
## Video
Debug modal for an `mbgljs` style on this branch:
https://github.com/user-attachments/assets/41a7bc71-85cf-44ae-a56e-91af7fbb3904
Fix written with Claude Code; video is an automated browser run of this
branch recorded by User Stories Bot.
Deleting a layer changes the starting indices of later groups, so their
stored expansion state no longer matches. Preserve that state through
surviving layer IDs when rebuilding the group keys.
This keeps expanded groups open after deleting an earlier layer or the
first layer of a group. Separate groups with the same prefix retain
their own states; if deletion joins two groups, the merged group stays
expanded when either was expanded.
- Fixes#1781.
Adds five deletion regression tests, a small style fixture, and a
changelog entry.
Validation:
- All 33 layer-list E2E tests and 50 unit tests pass.
- Lint and the production build, including TypeScript checking, pass.
- Manually checked OSM Liberty: all 15 groups remain expanded after
deleting the background layer.
- The full E2E suite reports 160 passing tests and one failure in
`modals > open > upload` (`Could not get styleItem from localStorage`).
The same failure reproduces with the original production code restored.
---------
Co-authored-by: Harel M <harel.mazor@gmail.com>
## Launch Checklist
This PR increases coverage by adding unit tests to lib folde, replace
the skipped end to end placeholder with actual tests and adds more end
to end tests.
This was mostly done by AI (Claude opus 4.8) and I reviewed it and
requested changes where needed.
- [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: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
## Launch Checklist
This PR replaces cypress with playwright.
<img width="1907" height="933" alt="image"
src="https://github.com/user-attachments/assets/b52075b3-eb3b-45dc-93dc-8c5e9cfd35dd"
/>
I hope this will make the end-to-end debugging and fixing easier due to
the async await support of playwright which is missing in cypress.
This is a pure refactoring change.
- [x] Briefly describe the changes in this PR.
- [x] Add an entry to `CHANGELOG.md` under the `## main` section.
---------
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>