Remove preventDefault() on touchstart and touchmove events#1195
Merged
stepankuzmin merged 2 commits intomapbox:mainfrom Sep 21, 2023
Merged
Remove preventDefault() on touchstart and touchmove events#1195stepankuzmin merged 2 commits intomapbox:mainfrom
stepankuzmin merged 2 commits intomapbox:mainfrom
Conversation
Touchstart and touchmove listeners added to the document by default as passive, so that calls to preventDefault will be ignored and will create a browser error like "Unable to preventDefault inside passive event". This resolves issues mapbox#1019, mapbox#1054
stepankuzmin
approved these changes
Sep 21, 2023
Contributor
stepankuzmin
left a comment
There was a problem hiding this comment.
Looks good to me, tested on Safari v17 iOS. Thanks for the contribution, @Archetylator!
This was referenced Sep 21, 2023
Merged
|
I am unable to get touch events on the map on mobile with these changes. Works for on desktop, but onClick never fired on mobile. |
danielsippel
added a commit
to danielsippel/mapbox-gl-draw
that referenced
this pull request
Apr 17, 2024
…apbox#1195)" This reverts commit 354e296.
danielsippel
added a commit
to danielsippel/mapbox-gl-draw
that referenced
this pull request
Apr 18, 2024
…vents (mapbox#1195)"" This reverts commit 31d3067.
manuelkasper
pushed a commit
to manuelkasper/mapbox-gl-draw
that referenced
this pull request
May 27, 2024
* Remove preventDefault() on touchstart and touchmove events Touchstart and touchmove listeners added to the document by default as passive, so that calls to preventDefault will be ignored and will create a browser error like "Unable to preventDefault inside passive event". This resolves issues mapbox#1019, mapbox#1054 * Revert comment before preventDefault and put it inside touchend
|
We are also having issues with onclick not being fired on mobile, and would appear the fix for this was reverted? |
masonwolters
added a commit
to masonwolters/mapbox-gl-draw
that referenced
this pull request
Jun 3, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Touchstart and touchmove listeners added to the document by default as passive, so that calls to preventDefault will be ignored and will create a browser error like "Unable to preventDefault inside passive event".
The difference between this solution and the previous one tring to fix that bug (5a90472) is that we leave preventDefault inside the touchend event.
More info on: https://chromestatus.com/feature/5093566007214080 and https://developer.mozilla.org/en-US/docs/Web/API/Pointer_events#compatibility_with_mouse_events
Fixes #1019