You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Fix editor map opening at the wrong zoom, and zoom 0 being reset, in WordPress 7 #3
The editor map can open at the wrong zoom in the WordPress 7 iframed editor, and a saved zoom of 0 is changed to 1.
Evidence
src/blocks/map/edit.js:163 and :258 use zoom || 1, so a saved zoom of 0 becomes 1.
The map container has minHeight: 250px and no fixed height (edit.js:148, :276). In the iframed editor, the container's height when the map is created can differ from its height after layout. Mapbox then raises the zoom so that the world fills the container, and the saved view is lost. The map is resized only when the aspect ratio changes (edit.js:265) and 250 ms after a selection change (edit.js:563), never after its first load. This cause is unconfirmed and needs a check in a WordPress 7 editor.
edit.js:13 imports __experimentalNumberControl. A WordPress 7.0 test should confirm that the inspector still renders.
Fix approach
Use zoom ?? 1 in both places.
On the map's first load event, call map.resize(), then map.jumpTo() with the saved centre and zoom.
Give the map container height: 100%, so that it follows its parent.
Check that dragging the map background doesn't jump in the WordPress 7.0 iframe. If it does, drive panning from pointer events on the iframe document.
Done when
A block with a saved view opens on that view in WordPress 7.0 and 7.1, including at zoom 0.
The block inspector opens without console errors.
Dragging the map background moves the map smoothly.
Thanks to @kadamwhite for asking us to check map-block after the WordPress 7 map fixes.
Dragging the map background in the editor does not follow the pointer in WordPress 7.1.3. The zoom fix for this issue does not change this, so it needs its own change.
The vertical jump equals the iframe's top offset, and the pointer did not move vertically.
With the iframe offset to the left, the horizontal pan no longer follows the pointer either.
Likely cause
mapbox-gl is bundled into the editor script, which runs in the parent window, while the map renders inside the canvas iframe. The drag handler appears to compare pointer positions from the two documents, which differ by the iframe's offset. This matches the vertical numbers exactly. The −37px horizontal value is not explained yet.
Fix approach
Drive background panning from pointer events on the iframe document (map.getCanvasContainer().ownerDocument), as the marker drag in src/blocks/map/edit.js already does, and disable Mapbox's own dragPan in the editor.
Done when
A 200px drag in the editor moves the map 200px in the drag direction and 0px across it, with the inserter both open and closed.
Update: #4 (Keep the saved view and fix background dragging in the WordPress 7 editor map) now fixes the background drag jump as well, so it covers this whole issue. The editor pans the map from pointer events in the iframe's document instead of using Mapbox's drag handling. We're checking the drag in the browser on WordPress 7.1.3, then running the full set of checks on WordPress 7.0.
Activity
svandragt commentedon Oct 19, 2026
Dragging the map background in the editor does not follow the pointer in WordPress 7.1.3. The zoom fix for this issue does not change this, so it needs its own change.
Evidence (wp-env, WordPress 7.1.3, Playwright, map at zoom 0, block selected, 200px horizontal drag)
Likely cause
mapbox-glis bundled into the editor script, which runs in the parent window, while the map renders inside the canvas iframe. The drag handler appears to compare pointer positions from the two documents, which differ by the iframe's offset. This matches the vertical numbers exactly. The −37px horizontal value is not explained yet.Fix approach
Drive background panning from pointer events on the iframe document (
map.getCanvasContainer().ownerDocument), as the marker drag insrc/blocks/map/edit.jsalready does, and disable Mapbox's owndragPanin the editor.Done when
A 200px drag in the editor moves the map 200px in the drag direction and 0px across it, with the inserter both open and closed.
Pan the editor map from pointer events in the iframe document
svandragt commentedon Oct 19, 2026
Update: #4 (Keep the saved view and fix background dragging in the WordPress 7 editor map) now fixes the background drag jump as well, so it covers this whole issue. The editor pans the map from pointer events in the iframe's document instead of using Mapbox's drag handling. We're checking the drag in the browser on WordPress 7.1.3, then running the full set of checks on WordPress 7.0.