mirror of
https://github.com/maputnik/editor.git
synced 2026-12-06 00:34:22 +00:00
253b58446254c6ca9dc92e4d810cef864972872c
11
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
253b584462 |
Build the layer options menu with downshift instead of react-aria-menubutton (#2409)
Closes #846. `react-aria-menubutton` was only used for the "Layer options" menu in the layer editor header. This PR builds that menu with `downshift`'s `useSelect`, which the project already uses for the autocomplete and sprite inputs, and removes `react-aria-menubutton` and its types from `package.json`. The menu is a new `LayerEditorMenu` component: - Same items, same `data-wd-key`s, and the button keeps the `skip-target-layer-editor` id, so the skip link still focuses it. - The menu closes after an action. The old menu stayed open (`closeOnSelection={false}`); it now uses `useSelect`'s default. - Arrow keys, Enter, Space and Escape work from the button. - In right-to-left languages the menu opens toward the inside of the layer editor. Its position now uses `inset-inline-end`, which replaces the separate `[dir="rtl"]` rule. One more change: the items already had a `disabled` flag for "Move layer up" on the first layer and "Move layer down" on the last one, but `react-aria-menubutton` never used it. `useSelect` supports it (`isItemDisabled`), so those two items are now dimmed and skipped. Screen readers now hear the button as a combobox with a listbox, the pattern `useSelect` follows, instead of a menu button. | Before | After | | --- | --- | |  |  | Both show the menu opened with the keyboard and the second item highlighted. The after image is on the first layer, so "Move layer up" is dimmed. **Performance:** no measurable impact. It's one small menu that only renders its items while open, and the bundle loses one dependency. ## Launch Checklist - [x] Briefly describe the changes in this PR. - [x] Link to related issues: #846. - [x] Include before/after visuals or gifs if this PR includes visual changes. - [x] Write tests for all new functionality: 5 e2e tests in `layer-editor.spec.ts` ("layer options menu"): keyboard selection, closing after a click, Escape, the disabled item (new `shouldBeDisabled` helper), and the menu staying inside the layer editor in Hebrew. The existing menu tests (delete and move via the menu, skip link) still pass. - [x] Add an entry to `CHANGELOG.md` under the `## main` section. Tested locally: `npm run lint` and `npm run lint-css` clean, `npx vitest run` (59 passed), full e2e with `npx playwright test` (231 passed). I also checked the menu by hand in English and Hebrew. Assisted-By: Claude Opus 5.5 (Claude Code). It helped write the component, the tests and this description. I've reviewed and tested the change and can answer questions about it. |
||
|
|
f5bd7c6176 |
Fill the style's center, zoom, bearing and pitch from the map (#2405)
Fixes #730. The Style Settings modal now has a "Use current map view" button above the Center field. It copies the map's current center, zoom, bearing and pitch into the style, so you don't have to copy them from the URL hash by hand. To make bearing and pitch available, the MapLibre map now reports them with center and zoom, and also reports after a rotate or pitch ends (before, only `dragend` and `zoomend` did). The OpenLayers renderer doesn't report bearing or pitch, so with it the button only fills center and zoom. Values are rounded before they go into the style: center to 5 decimals (about 1 m), zoom to 2, bearing and pitch to 1. Without that the style gets values like `2.1635000000000204`. The Center field gets a `key` that changes each time the button is clicked. `InputArray` only reads its value when it mounts, so it keeps half-typed coordinates while you edit, but that also means it wouldn't show a center set from outside. Remounting it on the button click shows the new center and leaves normal typing alone. **Before / after** (Style Settings): | Before | After | |---|---| | <img src="https://raw.githubusercontent.com/KhadeerBasha1232/maputnik/pr-assets/pr-730/before-style-settings.png" width="400"> | <img src="https://raw.githubusercontent.com/KhadeerBasha1232/maputnik/pr-assets/pr-730/after-style-settings.png" width="400"> | **Performance:** no measurable impact. The map calls the existing `onChange` once more at the end of a rotate or pitch gesture, which is the same work it already does after each drag and zoom. ## Launch Checklist - [x] Briefly describe the changes in this PR. - [x] Link to related issues: fixes #730. - [x] Include before/after visuals or gifs if this PR includes visual changes. - [x] Write tests for all new functionality: `use current map view copies the map's view into the style` in `modals.spec.ts` opens the map at zoom 5, sets bearing 12 and pitch 30 in the form, clicks the button and checks that the style has the map's center, zoom, bearing 0 and pitch 0. It fails on `main`, and it also fails if the map doesn't report bearing and pitch. A second test, `use current map view shows the map's center in the form`, checks that the Center input shows the new value. - [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 the full `npx playwright test` suite (222 passed). The first test fails on `main`, and also fails if I put back `main`'s `MapMaplibreGl.tsx`. 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. |
||
|
|
11c7daa2bb |
Change a layer's type from the layer editor (#2404)
Fixes #738. The layer editor's Type field was a read-only text box (`disabled={true}` on `FieldType`), so changing a layer's type meant editing the JSON. It's a dropdown again, the same one the Add Layer dialog uses. The `onChange` was already wired to `changeType()`, which keeps the paint and layout properties the new type supports and drops the rest. That's the behaviour agreed in the thread: keep what's shared, and the rest falls back to the spec defaults. Undo brings back the old layer. `changeType()` now also drops `source`, `source-layer` and `filter` when the new type is `background`, since a background layer can't have them and the style would otherwise fail validation. Other types keep all three. For example, a heatmap on a vector source still needs its `source-layer`. **Before / after** (layer editor, Type field): | Before | After | |---|---| | <img src="https://raw.githubusercontent.com/KhadeerBasha1232/maputnik/pr-assets/pr-738/before-layer-type.png" width="400"> | <img src="https://raw.githubusercontent.com/KhadeerBasha1232/maputnik/pr-assets/pr-738/after-layer-type.png" width="400"> | **Performance:** no impact. The change only runs when you pick a new type. ## Launch Checklist - [x] Briefly describe the changes in this PR. - [x] Link to related issues: fixes #738. - [x] Include before/after visuals or gifs if this PR includes visual changes. - [x] Write tests for all new functionality: `should change the layer type` in `layer-editor.spec.ts` (fails on `main`, where the field is a disabled text box), plus two `changeType` unit tests in `layer.test.ts` for the background case and for keeping source keys between other types. - [x] Add an entry to `CHANGELOG.md` under the `## main` section. Tested locally: `npm run lint` clean, `npx tsc --noEmit` clean, `npx vitest run` (59 passed) and the full `npx playwright test` suite (221 passed). With `main`'s `LayerEditor.tsx` and `layer.ts` put back, the new e2e test and the background unit test both fail. Assisted-By: Claude Opus 5.5 (Claude Code). It helped write the change, the tests and this description. I've reviewed and tested the change and can answer questions about it. Co-authored-by: Harel M <harel.mazor@gmail.com> |
||
|
|
b7b24e5de3 |
Open the color picker from the color swatch (#2406)
Fixes the second part of #677 ("clicking the swatch should open the color picker"). Only the text input next to a color swatch opened the picker; the swatch itself did nothing when clicked. The swatch now opens and closes the picker the same way, and shows a pointer cursor. It's `aria-hidden`, since the text input stays the control that screen readers and the keyboard use. I left the first part of the issue, the swatch's border and inset, alone. The thread didn't settle on one look for that. **Before / after:** no visual change other than the pointer cursor over the swatch; clicking it now opens the same picker the input opens. **Performance:** no impact. It adds one click handler per color field. ## Launch Checklist - [x] Briefly describe the changes in this PR. - [x] Link to related issues: part of #677. - [x] Include before/after visuals or gifs if this PR includes visual changes: no visual change apart from the cursor. - [x] Write tests for all new functionality: `opens the color picker when the color swatch is clicked` in `layer-editor.spec.ts`, with a `clickColorSwatch` driver action. It 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 the full `npx playwright test` suite: 217 passed, and the 4 that failed were Data Sources tests that hit `ERR_NETWORK_IO_SUSPENDED` while my PC slept. `modals.spec.ts` then passed in full on a rerun (64 passed). The new test fails when I put back `main`'s `InputColor.tsx`. 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. |
||
|
|
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 | |---|---| |  |  | 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. |
||
|
|
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. |
||
|
|
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 | | --- | --- | |  |  | |  |  | ## 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. |
||
|
|
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. |
||
|
|
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> |
||
|
|
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> |
||
|
|
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> |