Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bugfix] JS error on control removal #259

Merged
merged 3 commits into from
Feb 12, 2025

Conversation

titouanmathis
Copy link
Collaborator

@titouanmathis titouanmathis commented Feb 12, 2025

πŸ”— Linked issue

#249

❓ Type of change

  • πŸ“– Documentation (updates to the documentation, readme or JSdoc annotations)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • πŸ‘Œ Enhancement (improving an existing functionality like performance)
  • ✨ New feature (a non-breaking change that adds functionality)
  • 🧹 Chore (updates to the build process or auxiliary tools and libraries)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

πŸ“š Description

When unmounting the MapboxMap component, we call the map.remove() methods, which loops over all added controls and removes them. But, controls are also removed inside the useControl composable on unmount. This works fine with some controls but fails with the MapboxGeocoder component: it is first removed when calling map.remove() and then we try to remove it a second time, which fails because the container DOM element has already been removed (see https://github.com/mapbox/mapbox-gl-geocoder/blob/66c236f1f52d69bc2e2b5b8fb3ecc5255fc46acf/lib/index.js#L396-L408).

The fix is simple : we check if the map still has the control we want to remove before removing it, preventing calling the control's onRemove method twice.

πŸ“ Checklist

  • I have linked an issue or discussion.
  • I have added tests (if possible).
  • I have updated the documentation accordingly.
  • I have updated the changelog.

Copy link

netlify bot commented Feb 12, 2025

βœ… Deploy Preview for vue-mapbox-gl-demo ready!

Name Link
πŸ”¨ Latest commit 12ae5a9
πŸ” Latest deploy log https://app.netlify.com/sites/vue-mapbox-gl-demo/deploys/67acb5b58985d100083701ef
😎 Deploy Preview https://deploy-preview-259--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.

Copy link

github-actions bot commented Feb 12, 2025

Export Size

@studiometa/vue-mapbox-gl

Name Size Diff
useControl 1.03 kB +10 B (+0.98%) πŸ”Ί
MapboxGeolocateControl 1.34 kB +9 B (+0.68%) πŸ”Ί
MapboxNavigationControl 1.21 kB +8 B (+0.67%) πŸ”Ί
MapboxGeocoder 1.56 kB +6 B (+0.39%) πŸ”Ί
MapboxFullscreenControl 1.16 kB +3 B (+0.26%) πŸ”Ί
StoreLocator 5.41 kB +6 B (+0.11%) πŸ”Ί
Unchanged

@studiometa/vue-mapbox-gl

Name Size Diff
MapboxCluster 1.76 kB -
MapboxImage 656 B -
MapboxImages 880 B -
MapboxLayer 962 B -
MapboxMap 2.04 kB -
MapboxMarker 1.64 kB -
MapboxPopup 1.25 kB -
MapboxSource 437 B -
useEventsBinding 551 B -
useMap 166 B -
usePropsBinding 439 B -
VueScroller 634 B -

Copy link

codecov bot commented Feb 12, 2025

Codecov Report

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

Project coverage is 64.00%. Comparing base (5acb49e) to head (12ae5a9).
Report is 4 commits behind head on develop.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop     #259      +/-   ##
===========================================
- Coverage    64.13%   64.00%   -0.13%     
===========================================
  Files           22       22              
  Lines         2445     2445              
  Branches        70       70              
===========================================
- Hits          1568     1565       -3     
- Misses         875      878       +3     
  Partials         2        2              
Flag Coverage Ξ”
unittests 64.00% <100.00%> (-0.13%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

β˜” View full report in Codecov by Sentry.
πŸ“’ Have feedback on the report? Share it here.

@titouanmathis titouanmathis changed the base branch from develop to master February 12, 2025 14:53
@titouanmathis titouanmathis changed the base branch from master to develop February 12, 2025 14:53
@titouanmathis titouanmathis merged commit 441735f into develop Feb 12, 2025
13 of 14 checks passed
@titouanmathis titouanmathis deleted the bugfix/js-error-on-control-removal branch February 12, 2025 14:55
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