Commit Graph
16 Commits
Author SHA1 Message Date
FantasticSPMandFantasticSPM 1a2c3363ce fix: preview sprites for all sprite-backed properties (#2364)
## Description

The sprite picker added in #2359 only replaced the input for
`icon-image`. Maputnik already treats `background-pattern`,
`fill-pattern`, `line-pattern`, `fill-extrusion-pattern`, and
`icon-image` as sprite-backed properties through the shared
`iconProperties` list. The other four properties still rendered the
text-only autocomplete, so their dropdowns could not preview the sprite
atlas even though they use the same sprite catalog in the style spec.

This change routes every property in `iconProperties` through
`InputSprite`. Non-sprite string fields continue to use `InputString`,
and free-form values, search, keyboard selection, and expression editing
keep the behavior introduced in #2359. Having one special case for
`icon-image` and another branch for the remaining sprite properties was
redundant and left the UI inconsistent.

This is a follow-up to #2359 and completes the sprite-preview behavior
related to #1294 for all sprite-backed style properties.

## Visuals

No new visual treatment is introduced. Before this change, the four
pattern fields displayed the text-only autocomplete; after this change
they display the same thumbnail/search/keyboard picker already shown for
`icon-image` in #2359.

## Verification

- Added Playwright coverage for `background-pattern`, `fill-pattern`,
`line-pattern`, and `fill-extrusion-pattern`. Each case opens the
picker, verifies rendered atlas thumbnails, selects a sprite, and
asserts the persisted style value.
- `npm run lint`
- `npm run build`
- `npm run test-unit -- --run` (55 tests passed)
- `npm run test -- e2e/sprite-picker.spec.ts --workers=1` (19 tests
passed)
- Confirmed the new assertion fails when the expected option count is
deliberately mutated, then restored the assertion.
- Local `.npmrc` changes were not included in the commit.

## 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>
2026-11-25 10:43:11 +02:00
zstadler 129111357c Save global state values as JSON instead of strings, if possible (#2363)
To keep numbers, booleans, arrays and objects working in styles, the
Global State dialog now shows each non-string value as JSON. It also
saves entered values as JSON instead of a string, if possible. Text that
isn't valid JSON (like "value" or "#ff0000" without the quotes) is still
saved as a string. String values that look like JSON will be shown and
can be entered with quotes, e.g. `"9"`.

Resolves #2362

Created with [Claude AI](https://claude.ai)
2026-11-24 23:25:26 +02:00
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
shkomg 2ff1a62d19 Show boolean properties that default to true as checked (#2298)
Fixes #747

Boolean properties that default to `true` (`fill-antialias`,
`text-keep-upright`, `fill-extrusion-vertical-gradient`) showed an empty
checkbox when unset, so the first click wrote `true` and nothing changed
on the map. `InputCheckbox` now falls back to the spec default that
`InputSpec` already passes (as `InputEnum` does), and a click toggles
from what is shown. The Cluster checkbox in the sources modal passes no
default, so it behaves as before.

## 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 two e2e tests on `fill-antialias` (checked when unset, one click
writes `false`).

## Screenshots

"Extrusion vertical gradient" on a `fill-extrusion` layer with the
property unset, before and after:

| Before | After |
| --- | --- |
|
![before](https://github.com/user-attachments/assets/a2f4f4d2-9b1e-4b1b-89db-2a6a1f0b922a)
|
![after](https://github.com/user-attachments/assets/64e79b7b-1a9c-40e6-8040-9ac082ef998c)
|
| ![before,
zoomed](https://github.com/user-attachments/assets/482cb984-4927-4e32-81cb-2fce75c3a25d)
| ![after,
zoomed](https://github.com/user-attachments/assets/5d135d3d-910a-49ff-9837-b931132e7a30)
|

## Video

The video shows the same row on a small extrusion style, and one click
turning the gradient off.


https://github.com/user-attachments/assets/8ebc2f5a-923b-4022-82da-07cbd1eda783

Fix written with Claude Code; video is an automated browser run of this
branch recorded by User Stories Bot.
2026-11-03 17:22:41 +02:00
shkomg 3f3ca9a13b Fix debug modal options missing for the mbgljs renderer (#2293)
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.
2026-11-03 08:16:19 +02:00
Harel M 68c81fc7a3 feat: Add ability to control the max zoom of the map (#2201)
- Resolves #2202

## Launch Checklist

The map max zoom was increased to 24 without the ability to change it.
- https://github.com/maplibre/maputnik/issues/593

The default is 22 for all maplibre instances if you don't override it in
your code.
The zoom levels to over scale is dependent on max zoom, which can affect
how the map looks.
This PR adds the ability to change this.
This was added to the debug dialog:
<img width="446" height="446" alt="image"
src="https://github.com/user-attachments/assets/ea68c392-309f-4476-8922-790670762d56"
/>


 - [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.
2026-10-05 15:49:55 +03:00
Harel M 560478410a Add font-faces, sky, roll and centerAltitude (#2189)
After: 
<img width="425" height="366" alt="image"
src="https://github.com/user-attachments/assets/f737de31-57e8-4445-b114-a5acdabb619c"
/>



## Launch Checklist

 - [x] Briefly describe the changes in this PR.
- [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.
2026-09-27 20:05:23 +03:00
Harel MandBart Louwers 2384adf517 feat: make sidebar panels resizable (#2094)
- Replaces #1870, which replaced #1682, #1677

This mostly uses the code from there and addresses the comments I've
left. I didn't change the code much.

## Launch Checklist

Makes the sidebar panel resizable

<img width="707" height="511" alt="image"
src="https://github.com/user-attachments/assets/d010df38-faac-441c-bf7f-a4960e471c61"
/>


 - [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: Bart Louwers <bart.louwers@gmail.com>
2026-09-27 13:44:22 +00:00
a3e9c91ce0 chore: stabilize Playwright E2E runs (#2164)
#1351 made `styleStore` initialization asynchronous in
`componentDidMount`. `setStyle` currently treats `toolbar:link`
appearing as the signal that loading is complete, but if the style
network request (`empty-style.json` from jsdelivr) takes over ~1s, the
`toolbar:link` can appear while `styleStore` is still null (because the
request has not finished). Subsequent `saveStyle` calls in tests then
silently do nothing, causing test failures (3 in #2157, and often 20+ on
my machine).

Changes are:

1. Mock the default empty style to avoid slow network E2E failures.
2. Also cap Playwright workers at 4 to avoid overloading Chromium on
high-core machines.

Fixes #2158.

## Launch Checklist

<!-- Thanks for the PR! Feel free to add or remove items from the
checklist. -->


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

Co-authored-by: liuly <me@liuly.moe>
Co-authored-by: Harel M <harel.mazor@gmail.com>
2026-09-14 19:05:28 +03:00
CHIIMYEN 95bf5f2c55 Fix keyboard shortcuts being ignored while the map has focus (#2157)
## Launch Checklist

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

### What changed

Keyboard shortcuts went dead as soon as the map had focus.

The global `keyup` handler in `App.tsx` gated shortcuts on
`document.activeElement === document.body`. That reads like "the user is
not
typing", but it actually asks "is nothing focused at all". Clicking the
map makes
`.maplibregl-canvas` the active element, so every shortcut stopped
working until the
map was blurred.

The `m` shortcut demonstrates the problem nicely: its entire job is to
focus that
canvas, so pressing `m` silently disabled all shortcuts until `Esc`.
That path is
covered by an existing test (`'m' should focus map`), which is why the
regression
was easy to miss.

### How

`isTextEntryElement()` now answers the question the guard was reaching
for, so
shortcuts are suppressed only for text entry targets:

`input`, `textarea`, `select`, and `contenteditable` — the last one
covering the
CodeMirror editor, which is a `contenteditable` `.cm-content`.

The check stays independent of either renderer's DOM. MapLibre's
`.maplibregl-canvas` and the OpenLayers viewport live in different
structures, so an
allow-list of canvas class names would have fixed one renderer and left
the other
broken.

### Behaviour change

Single-letter shortcuts now also fire while focus is on a button or a
panel, where
previously they did not. That is inherent to making the map case work —
the old
predicate simply excluded everything that was not `document.body`. Per
@HarelM, this
can be reverted if anyone complains.

### Tests

`e2e/keyboard.spec.ts` gains a `while the map has focus` block. Its
`beforeEach`
focuses the canvas through the `m` shortcut and asserts the canvas
really is focused,
then two independent tests check that `!` and `s` still open their
modals.

Verified the new tests fail without the fix:

```
Error: expect(locator).toBeVisible() failed
Locator: locator('[data-wd-key="modal:debug"]').first()
Expected: visible
Error: element(s) not found
```

and pass with it.

Local results:

| Check | Result |
|---|---|
| `npm run lint` | clean |
| `npx vitest run` | 9 files, 50 tests passed |
| `npx vite build --mode=production` | clean |
| `npx playwright test` | 170 passed, 3 failed |

The 3 failures — `modals › open › upload via drag and drop`,
`modals › global state › remove variable` and `modals › global state ›
edit variable key`
— also fail on unmodified `main`, so they are pre-existing and unrelated
to this
change.

Fixes #940
2026-09-14 08:33:39 +03:00
liuly 80c0d08179 Fix zoom property crash after deleting a stop (#2153)
## Launch Checklist

<!-- Thanks for the PR! Feel free to add or remove items from the
checklist. -->

When a fixed paint value is converted to a zoom function, Maputnik
creates exactly two stops.

<img width="362" height="226" alt="image"
src="https://github.com/user-attachments/assets/209aebbf-7bb3-4422-b0c7-1019e20a9ddb"
/>

Deleting either one of those two stops leaves a single remaining value.
During the transition back to the ordinary field editor, `ZoomProperty`
can render with `stops` undefined. It previously called `.map`
unconditionally, causing the editor to crash.

<img width="2551" height="1248" alt="image"
src="https://github.com/user-attachments/assets/f5c2af59-dcae-4ffe-8245-f175eea9c843"
/>

This PR guards the stop list with optional chaining. The change only
protects the render path and does not alter zoom-function conversion or
value persistence.

Now, the remaining stop's value will be restored after deleting the
other stop:

<img width="367" height="168" alt="image"
src="https://github.com/user-attachments/assets/8d13236b-6140-451b-8613-0bc5f11893de"
/>

The regression test covers `circle-opacity`:

1. Convert a fixed value to a zoom function.
2. Change the second stop's value.
3. Delete the first of the two stops.
4. Verify that the ordinary field editor reappears.
5. Verify that the remaining stop's value is restored.
6. Edit the restored field and verify that the style updates
successfully.

 - [x] Briefly describe the changes in this PR.
 - [ ] 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.
2026-09-09 18:04:32 +03:00
Nikita Maximilian GrimmandHarel M 1301dc03e7 Fix layer group expansion state after deletion (#2146)
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>
2026-09-08 18:33:00 +00:00
Jamal Ali c0f76dfff8 fix(layer-list): title visibility button with the action it performs (#2135)
- Fixes #1675

## Problem

In the layer list, the show/hide button's `title` tooltip named the
layer's
current visibility instead of what a click does. A visible layer's
button read
`show` while clicking it hides the layer, and a hidden layer's button
read
`hide` while clicking it shows the layer — exactly reversed.

`LayerListItem.tsx` derived a single value from the layer state:

```ts
const visibilityAction = visibility === "visible" ? "show" : "hide";
```

and passed it to `IconAction` as `action`, which `IconAction` used for
three
different things: choosing the icon, building the `--show`/`--hide` CSS
modifier, and rendering `title={this.props.action}`. The first two are
correct
as a state indicator; only the tooltip needs the opposite verb.

## Change

- `IconAction` gets an optional `title` prop and falls back to `action`
when it
  is not given, so the delete and duplicate buttons are unchanged.
- `LayerListItem` keeps `visibilityAction` (icon +
`maputnik-layer-list-icon-action__visibility--hide`
CSS modifier, which `_layer.scss` relies on to keep the button visible
for
  hidden layers) and adds `visibilityTitle` for the inverted tooltip.

No icon, class name or click behaviour changes.

## Test

New regression test in `e2e/layers-list.spec.ts`: it asserts the button
is
titled `hide` while the layer is visible, clicks it, and asserts it is
titled
`show` once the layer is hidden. Against the unpatched component the
first
assertion fails with `Expected: "hide"` / `Received: "show"`,
reproducing the
reported behaviour.

`npm run lint`, `npx tsc --noEmit`, `npx vitest run` (50 tests) and
`npx playwright test e2e/layers-list.spec.ts` (28 tests) all pass.

## Note

The tooltips in this component (`delete`, `duplicate`, `show`, `hide`)
are
plain English literals and are not run through `t()` today, so this
change
keeps them as-is rather than introducing translation keys for one
button. Also
worth flagging separately: these buttons carry `aria-hidden="true"`, so
the
`title` never reaches assistive technology at all — out of scope here,
but it
means the label is a mouse-hover tooltip only.
2026-09-06 00:12:24 +03:00
f14eeae38b Increase coverage (#1997)
## 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>
2026-07-12 15:46:30 +03:00
2e0b7cdb8c Replace cypress with playwright (#1988)
## 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>
2026-07-10 18:18:48 +00:00
Harel MandClaude Opus 4.8 be9456d11b Relocate e2e tests (#1989)
## Launch Checklist

Renames the e2e test and reduces changes as a preparation step from
playwright in the following PR:
- #1988

This is to keep as much history as possible.
<img width="1907" height="933" alt="image"
src="https://github.com/user-attachments/assets/b52075b3-eb3b-45dc-93dc-8c5e9cfd35dd"
/>

 - [x] Briefly describe the changes in this PR.

---------

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-09 11:38:59 +03:00