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 for events type 'mouseover' 'mouseout' etc #5464

Open
ToHold opened this issue Feb 5, 2025 · 3 comments · May be fixed by #5466
Open

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

ToHold opened this issue Feb 5, 2025 · 3 comments · May be fixed by #5466
Labels
bug Something isn't working enhancement New feature or request PR is more than welcomed Extra attention is needed

Comments

@ToHold
Copy link
Contributor

ToHold commented Feb 5, 2025

User Story

As a developer for a company using maplibre as map engine for their website, I am facing an issue from Sentry. After analysing this issue, it appears that some facebook bots are crawling our website. They're dispatching events on the page, and some of their events are MouseEvents (mouseover, mouseout etc...). But during maplibre event handling, it crashes with an Invalid LngLat object: (NaN, NaN) Error.
I found a way to reproduce it and I determined that it crashes because they dispatch Event and not MouseEvent.
There's an easy way to reproduce : https://codepen.io/ToHold/pen/dPbBPJX
I know this is not a bug, developers should use MouseEvent, but in this case, we can't change what these bots are doing, that's why I'm asking it as feature request.

Rationale

I've seen that we are not alone facing this issue.
It would be easy to fix, a simple if (!event instanceof MouseEvent) return; would fix it.

Impact

Without this simple check, map can throw an unhandled error.

@ToHold
Copy link
Contributor Author

ToHold commented Feb 5, 2025

If you agree with this feature, I can prepare a PR for this asap.

@HarelM
Copy link
Collaborator

HarelM commented Feb 5, 2025

Please open a PR and we'll see how complicated the fix is.
If this is a simple fix that doesn't change a lot of code for this edge case, I'm OK with introducing it to the code base.

@HarelM HarelM added bug Something isn't working enhancement New feature or request PR is more than welcomed Extra attention is needed labels Feb 5, 2025
@ToHold ToHold linked a pull request Feb 5, 2025 that will close this issue
8 tasks
@ToHold
Copy link
Contributor Author

ToHold commented Feb 5, 2025

Fixed here : #5466

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request PR is more than welcomed Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants