Skip to content

Conversation

@steklopod
Copy link

#249

Fix MapBox removal error and improve cleanup

Issue

When navigating between pages, the following error occurs:
TypeError: Cannot read properties of null (reading 'removeChild')

This is related to a timing issue during map cleanup that has been present since MapBox GL 2.6.0.

What's Changed

  • Fixed map removal error by:
    • Adding proper cleanup sequence in onUnmounted
    • Using nextTick to ensure DOM is in correct state before removal
    • Adding null checks for map instance
  • Improved ResizeObserver cleanup to prevent memory leaks
  • Enhanced TypeScript typings for better type safety

Technical Details

  • Store ResizeObserver reference on map instance for reliable cleanup
  • Added proper checks before map removal operations
  • Implemented safer unmounting sequence using Vue's nextTick
  • Added MapWithResizeObserver interface for type safety

@netlify
Copy link

netlify bot commented Feb 6, 2025

👷 Deploy request for vue-mapbox-gl pending review.

Visit the deploys page to approve it

Name Link
🔨 Latest commit a69ad6c

@netlify
Copy link

netlify bot commented Feb 6, 2025

Deploy Preview for vue-mapbox-gl-demo ready!

Name Link
🔨 Latest commit a69ad6c
🔍 Latest deploy log https://app.netlify.com/sites/vue-mapbox-gl-demo/deploys/67a50c6971e163000883c1ce
😎 Deploy Preview https://deploy-preview-254--vue-mapbox-gl-demo.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@titouanmathis
Copy link
Collaborator

titouanmathis commented Feb 12, 2025

#249 has been fixed by #259, the other changes should be made in another PR.

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.

2 participants