Commit Graph
7 Commits
Author SHA1 Message Date
SHAIK KHADEER BASHA 87fe93bc03 Keep the color picker within the viewport (#2398)
Fixes #717.

The color picker opened at a fixed offset next to its input
(`calcPickerOffset`), so near the bottom or right edge of the window
part of it was cut off. It now measures the panel after it opens and
places it on the inline-end side of the input (the right in LTR, the
left in RTL), switching sides only when there's no room, then clamps it
inside the viewport with an 8px margin. It repositions on resize and
scroll while open, and on very short windows the panel scrolls instead
of overflowing. The panel stays hidden for the first render until it has
a position, so it doesn't flash at the old spot.

| Before | After |
|---|---|
|
![before](https://raw.githubusercontent.com/KhadeerBasha1232/maputnik/pr-assets/pr-2398/before.png)
|
![after](https://raw.githubusercontent.com/KhadeerBasha1232/maputnik/pr-assets/pr-2398/after.png)
|

Both open the `background-color` picker with the field at the bottom of
a 1280px-wide window, in Chromium.

In the issue, orangemug suggested opening the picker inside the editor
panel instead of over the map. I kept the existing popover here because
that's a much smaller change and fixes the clipping on its own; moving
the picker into the panel would change the layout of every color field.

**Performance:** the resize and scroll listeners are only attached while
a picker is open and are removed when it closes or unmounts. Each event
does two `getBoundingClientRect` calls and only sets state when the
position actually changes.

## Launch Checklist

 - [x] Briefly describe the changes in this PR.
 - [x] Link to related issues: fixes #717.
- [x] Include before/after visuals or gifs if this PR includes visual
changes.
- [x] Write tests for all new functionality: two e2e tests in
`layer-editor.spec.ts`. One opens the picker with its field at the
bottom of the window and checks the whole picker is in the viewport; it
fails on `main`. The other switches to Hebrew and checks the picker
opens to the left of its field; it fails when I force the LTR side.
`shouldBeInViewport` in the helper now takes an optional ratio for the
first one.
 - [x] Add an entry to `CHANGELOG.md` under the `## main` section.

Tested locally: `npm run lint` clean, `npx tsc --noEmit` clean, `npx
vitest run` (57 passed) and `npx playwright test
e2e/layer-editor.spec.ts e2e/sprite-picker.spec.ts` (75 passed;
`sprite-picker` also uses `shouldBeInViewport`). The new test fails when
I run it against `main`. I didn't run the full e2e suite locally (it
times out on Windows with several workers); it passes in CI on this PR.

Assisted-By: Claude Opus 5.5 (Claude Code). It helped write the change,
the test and this description. I've reviewed and tested the change and
can answer questions about it.
2026-12-04 12:02:08 +02:00
SHAIK KHADEER BASHA 3e6e558d63 Commit a layer rename once on Enter or blur (#2396)
Fixes #1269.

Renaming a layer ran the whole rename on every keystroke:
`onLayerIdChange` updated the style, which was validated, saved to
localStorage and pushed to the map for each intermediate ID. The layer
editor's ID field now keeps the draft in the input and commits it on
Enter or blur, which is how `InputString` already behaves for other
string fields. `FieldId` gets a `commitOnBlur` prop for this; the Add
Layer dialog doesn't pass it, so it still updates its draft ID as you
type.

The issue suggests debouncing. I went with commit on Enter/blur instead
because a debounced rename would still apply half-typed IDs whenever
typing pauses, and each of those is a real rename of the layer in the
style.

No visual change: the field looks the same, the new ID is just applied
when you leave the field.

**Performance:** I typed a 20-character ID into the layer ID field with
Playwright (`keyboard.type`, then Tab), 5 runs each in Chromium on the
dev server, counting style writes to localStorage:

| | Style saves per rename | Time to type the 20 characters (median) |
|---|---|---|
| `main` | 20 | 2105 ms |
| this PR | 1 | 92 ms |

The timings are from my Windows laptop with an e2e run going in the
background, so only the ratio matters.

## Launch Checklist

 - [x] Briefly describe the changes in this PR.
 - [x] Link to related issues: fixes #1269.
- [x] Include before/after visuals or gifs if this PR includes visual
changes: no visual change.
- [x] Write tests for all new functionality: the `id` test in
`layer-editor.spec.ts` now checks that the saved style still has the old
ID after typing, before the field loses focus. That check fails on
`main`.
 - [x] Add an entry to `CHANGELOG.md` under the `## main` section.

Tested locally: `npm run lint` clean, `npx tsc --noEmit` clean, `npx
vitest run` (57 passed) and `npx playwright test
e2e/layer-editor.spec.ts` (52 passed). The updated `id` test fails when
I run it against `main`. I didn't run the full e2e suite locally (it
times out on Windows with several workers); it passes in CI on this PR.

Assisted-By: Claude Opus 5.5 (Claude Code). It helped write the change,
the test and this description. I've reviewed and tested the change and
can answer questions about it.
2026-12-04 10:37:57 +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
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
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