vue-mapbox-gl icon indicating copy to clipboard operation
vue-mapbox-gl copied to clipboard

[Bugfix] Fix MapBox removal error and improve cleanup

Open steklopod opened this issue 9 months ago • 3 comments

https://github.com/studiometa/vue-mapbox-gl/issues/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

steklopod avatar Feb 06 '25 19:02 steklopod

Deploy request for vue-mapbox-gl pending review.

Visit the deploys page to approve it

Name Link
Latest commit a69ad6cba38008f277469b39203948a42c602f0d

netlify[bot] avatar Feb 06 '25 19:02 netlify[bot]

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

Name Link
Latest commit a69ad6cba38008f277469b39203948a42c602f0d
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.

netlify[bot] avatar Feb 06 '25 19:02 netlify[bot]

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

titouanmathis avatar Feb 12 '25 16:02 titouanmathis