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

Fix NavigationControl compass regression #5205

Merged
merged 6 commits into from
Dec 15, 2024

Conversation

raboczi
Copy link
Contributor

@raboczi raboczi commented Dec 14, 2024

Launch Checklist

See #5195 for discussion.

I think the regression was caused by "TouchEvent" only being defined on Chromium-derived and/or touchscreen-equipped browsers, such that the drag handler would fail on Firefox and Safari on my Mac laptop.

This PR does two things:

  • Adds a typeof TouchEvent !== 'undefined' check to prevent a runtime error when it's undefined.
  • Consolidates the type checks into an _onMouseEventOrTouchEvent method to reduce duplication, possibly at the cost of clarity.
  • Confirm your changes do not include backports from Mapbox projects (unless with compliant license) - if you are not sure about this, please ask!
  • Briefly describe the changes in this PR.
  • Link to related issues.
  • Include before/after visuals or gifs if this PR includes visual changes.
  • Write tests for all new functionality.
  • Document any changes to public APIs.
  • Post benchmark scores.
  • Add an entry to CHANGELOG.md under the ## main section.

Copy link

codecov bot commented Dec 14, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 91.82%. Comparing base (f1a70c0) to head (6442272).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5205      +/-   ##
==========================================
- Coverage   91.83%   91.82%   -0.01%     
==========================================
  Files         281      281              
  Lines       38777    38786       +9     
  Branches     6756     6762       +6     
==========================================
+ Hits        35609    35614       +5     
- Misses       3041     3044       +3     
- Partials      127      128       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@HarelM
Copy link
Collaborator

HarelM commented Dec 14, 2024

Thanks!!

Other places in the code are using: typeof ...
Like here:

supportsOffscreenCanvas = typeof OffscreenCanvas !== 'undefined' &&

Let's keep it similar and avoid the need to write "window.".

@raboczi
Copy link
Contributor Author

raboczi commented Dec 14, 2024

Let's keep it similar and avoid the need to write "window.".

Rewrote it with typeof TouchEvent !== 'undefined'. Still seems to work.

@HarelM
Copy link
Collaborator

HarelM commented Dec 14, 2024

Overall this looks great, thanks!
If there's a way to reproduce this issue in a simple unit test that can be great.

@HarelM
Copy link
Collaborator

HarelM commented Dec 15, 2024

Looks good! Can you add a changelog item?
I'm not sure how to properly test this, so if you find a way great, otherwise I'll merge as is.

@raboczi
Copy link
Contributor Author

raboczi commented Dec 15, 2024

Looks good! Can you add a changelog item?

Done!

I'm not sure how to properly test this, so if you find a way great, otherwise I'll merge as is.

I can't run the existing test suite locally, so I wouldn't dare to try adding my own new stuff to it.

@HarelM HarelM merged commit 414e474 into maplibre:main Dec 15, 2024
16 of 17 checks passed
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