Skip to content

fix(post-location): fix map rendering and marker on new posts#62

Merged
techtimo merged 1 commit into
mainfrom
fix/post-location-new-posts
Apr 28, 2026
Merged

fix(post-location): fix map rendering and marker on new posts#62
techtimo merged 1 commit into
mainfrom
fix/post-location-new-posts

Conversation

@techtimo

Copy link
Copy Markdown
Owner

Summary

  • Leaflet CSS not loaded on new posts β€” enqueue_block_editor_assets() called enqueue_styles() which bails early via should_enqueue() when the post has no Spotmap block yet. Replaced the call with a direct wp_enqueue_style() so the CSS is always loaded in the editor.
  • Tiles overflowing the map container β€” added overflow: hidden and position: relative to the map container div (belt-and-suspenders, since Leaflet CSS also sets this on .leaflet-container). Without CSS loaded, tiles bled outside the div and sat on top of the Clear location button, causing apparent click misses and tiny coordinate shifts from accidental map clicks.
  • BeautifyIcon marker β€” replaced the default Leaflet PNG marker (broken URL in editor context) with L.BeautifyIcon using the POST type config from spotmapjsobj.marker (thumbtack icon by default, respects admin customisation).

Test plan

  • Open a brand-new post in the block editor β€” map renders correctly, tiles stay inside the container, attribution is visible
  • Click on the map to set a location β€” BeautifyIcon thumbtack marker appears
  • Drag the marker β€” coordinates update
  • Click Clear location β€” marker disappears, coordinates cleared
  • Open an existing post with a Spotmap block β€” no regression in map or block behaviour

Without a Spotmap block, should_enqueue() returned false and Leaflet CSS
was never loaded in the block editor. This caused tiles to overflow the
map container and cover the Clear location button, making it appear
unresponsive on new posts.

- Always enqueue spotmap-map.css in enqueue_block_editor_assets(),
  bypassing the should_enqueue() guard
- Add overflow:hidden + position:relative to the map container div
- Replace default Leaflet PNG marker with L.BeautifyIcon using the
  POST marker config from spotmapjsobj (thumbtack icon by default)
@codecov

codecov Bot commented Apr 21, 2026

Copy link
Copy Markdown

Codecov Report

βœ… All modified and coverable lines are covered by tests.

πŸ“’ Thoughts on this report? Let us know!

@techtimo techtimo merged commit 0982548 into main Apr 28, 2026
5 checks passed
@techtimo techtimo deleted the fix/post-location-new-posts branch April 28, 2026 18:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant