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

feat(events): check if event instanceof MouseEvent #5466

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

ToHold
Copy link
Contributor

@ToHold ToHold commented Feb 5, 2025

Fix an error that could happen if a instance of Event is dispatched with MouseEvent types. This error has been encountered only when bots were crawling a website where a maplibre map was instanced.

Launch Checklist

  • 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.

src/ui/handler_manager.ts Outdated Show resolved Hide resolved
@ToHold ToHold force-pushed the feat-check-if-event-instanceof-MouseEvent branch from 6370d49 to 21c439e Compare February 6, 2025 09:00
Copy link

codecov bot commented Feb 6, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 91.99%. Comparing base (a99fe93) to head (36eadfd).
Report is 5 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5466      +/-   ##
==========================================
+ Coverage   91.96%   91.99%   +0.03%     
==========================================
  Files         282      282              
  Lines       39050    39086      +36     
  Branches     6855     6868      +13     
==========================================
+ Hits        35911    35956      +45     
+ Misses       3012     3001      -11     
- Partials      127      129       +2     

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

@ToHold ToHold force-pushed the feat-check-if-event-instanceof-MouseEvent branch 3 times, most recently from 46694f8 to 1316f24 Compare February 6, 2025 10:08
src/util/util.ts Outdated Show resolved Hide resolved
@ToHold ToHold force-pushed the feat-check-if-event-instanceof-MouseEvent branch from 1316f24 to 640cb5c Compare February 10, 2025 13:57
src/ui/handler_manager.ts Outdated Show resolved Hide resolved
CHANGELOG.md Outdated Show resolved Hide resolved
src/ui/handler_manager.ts Outdated Show resolved Hide resolved
src/ui/handler_manager.ts Outdated Show resolved Hide resolved
src/ui/handler_manager.ts Outdated Show resolved Hide resolved
@ToHold ToHold force-pushed the feat-check-if-event-instanceof-MouseEvent branch from 640cb5c to b11844f Compare February 12, 2025 16:31
@ToHold
Copy link
Contributor Author

ToHold commented Feb 13, 2025

Tests were ok in local, I will check during the day why it fails.

@ToHold ToHold force-pushed the feat-check-if-event-instanceof-MouseEvent branch 2 times, most recently from 5a8bccd to 58ed29e Compare February 13, 2025 13:04
check if event is instance of MouseEvent in map_event.ts
same for event.ts

Fix 5464
@ToHold ToHold force-pushed the feat-check-if-event-instanceof-MouseEvent branch from 58ed29e to 36eadfd Compare February 13, 2025 13:06
@ToHold
Copy link
Contributor Author

ToHold commented Feb 13, 2025

Should I update the bundle size test, or will a collaborator handle it?

@HarelM
Copy link
Collaborator

HarelM commented Feb 13, 2025

Please update the build size. Thanks!

return pointableEvents[eventType] && (event instanceof MouseEvent || event instanceof WheelEvent);
}

export function isTouchableOrPointableType(eventType: string): boolean {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure I fully see the value of this method, when used it is in an "if" statement that a simple else cover, doesn't it?


const pointableEvents = {
dblclick: true,
click: true,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Click can be achieved in touch devices, can't it?

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.

feat(events): check if event instanceof MouseEvent for events type 'mouseover' 'mouseout' etc
3 participants