fix: move a Map component when its longitude, latitude or zoom is set to 0

Merged
BU
1d ago
+3-2

What does this PR do?

In the low-code app editor, a Map component ignores a Longitude, Latitude or Zoom set to 0. Set Longitude to 0 (the Greenwich meridian) and the map does not move; set Zoom to 0 (the whole world) and it does not zoom out. The values are saved: after a reload the map opens where they say, so only the live edit was lost.

The effects that apply them read map && resolvedConfig.longitude && resolvedConfig.latitude and map && resolvedConfig.zoom, so a 0 failed the truthiness test. While Longitude was 0, && also stopped before reading Latitude, so latitude edits were not tracked either. This PR checks for a value (!= undefined) instead, as the map's initial view already does with ??. One file, AppMap.svelte, 3 lines added and 2 removed.

Reproduced on main at 18d0a78 (backend CE v1.875.0).

flowchart TD
    A[Builder sets Longitude or Zoom of a Map to 0] --> B{Map view}
    B -->|Before| C[Stays where it was]
    B -->|After| D[Moves to longitude 0 or zooms out to the whole world]

Narrated recording, before then after (sound on):

https://github.com/user-attachments/assets/d16d874e-ee19-4f8c-9e6f-ac7f6cd32e42

The recording is the real app (frontend dev server from this checkout against the main backend image). Waits on page loads are shortened; nothing else is edited.

Edge cases and unchanged behaviour checked

All checked in the running app, on this branch:

  • With Longitude 0, Latitude edits are followed: 0 centers the map on the equator, then 51.48 brings it back to Greenwich.
  • A cleared Latitude leaves the map where it is (no blank map).
  • Unchanged: non-zero values still move the map (Longitude 2.35, Latitude 48.86 centers it on Paris).
  • Unchanged: Zoom 6 still zooms in.

Checks run

  • npm run lint (oxlint): passes.
  • prettier --check on the changed file: the lines changed here are formatted; the file already fails the check on main because of three unrelated long lines, which this PR leaves alone.
  • Not run: npm run check (svelte-check needs about 8 GB here) and npm run check:fast (no bun on this machine).
  • No test added: docs/validation.md asks for none on pure UI changes.

Related issue

None filed. Found while building a low-code app with a Map component.

AI tools (Claude Code) assisted with this change; the bug was reproduced on main and the fix verified in the running app as shown.


Summary by cubic

Fixes the low-code Map component ignoring Longitude, Latitude, or Zoom set to 0, so live edits now move the map to the Greenwich meridian, the equator, or zoom out to the whole world.

The effects that apply center and zoom used truthiness checks, so 0 values were skipped and a latitude change was also ignored while longitude was 0. They now check for a value instead. Non-zero values and cleared fields behave as before.