Skip to content

Enable touch event propagation properly#869

Closed
godismyjudge95 wants to merge 5 commits intomapbox:mainfrom
godismyjudge95:patch-1
Closed

Enable touch event propagation properly#869
godismyjudge95 wants to merge 5 commits intomapbox:mainfrom
godismyjudge95:patch-1

Conversation

@godismyjudge95
Copy link
Copy Markdown

This is to fix #617
It allows the event to propagate through if there are no mapbox targets nearby.
This sort of breaks the one tap move drawing functionality, but still allows for the double tap to move the drawing.
It also enables popups and clusters to work again.

I believe this is the best temporary solution until another is found. The one provided by @Plantain here: #830
basically broke drawing completely on some browsers. I have tested extensively and am employing the patch to all my apps.

This is to fix #617
It allows the event to propagate through if there are no mapbox targets nearby.
This sort of breaks the one tap move drawing functionality, but still allows for the double tap to move the drawing.
It also enables popups and clusters to work again.

I believe this is the best temporary solution until another is found.  The one provided by @Plantain here:  #830
basically broke drawing completely on some browsers.  I have tested extensively and am employing the patch to all my apps.
@rdgfuentes
Copy link
Copy Markdown

Thanks for proposing this fix! Take a look at the continuous integration check that failed, you have some trailing spaces that are not allowed by the linter:

/home/travis/build/mapbox/mapbox-gl-draw/src/events.js
   90:1  error  Trailing spaces not allowed  no-trailing-spaces
   95:1  error  Trailing spaces not allowed  no-trailing-spaces
   99:1  error  Trailing spaces not allowed  no-trailing-spaces
  120:1  error  Trailing spaces not allowed  no-trailing-spaces
  125:1  error  Trailing spaces not allowed  no-trailing-spaces
  127:1  error  Trailing spaces not allowed  no-trailing-spaces

@aptlin
Copy link
Copy Markdown

aptlin commented Mar 26, 2019

@godismyjudge95, could you please fix the trailing spaces for the PR to merge?

@godismyjudge95
Copy link
Copy Markdown
Author

@sdll @rdgfuentes It appears my fix is interfering with tests 498-502... This is due to my original statement: "This sort of breaks the one tap move drawing functionality," however, this is a necessary trade off until we can figure out another solution.

To see a demo of the issue I am talking about go to this website: https://www.terraplat.com/
The drawing works perfectly until you try to resize it. In order to resize, you need to click once on the point to select it, and then click and drag to move the point. I realize this is less intuitive than clicking once and dragging, however, the client needed to have clusters and drawing and popups functioning... This patch was the only way we could get all 3 working together.

@kjkurtz
Copy link
Copy Markdown

kjkurtz commented Nov 22, 2019

Any further thoughts on how to keep this moving forward? Definitely causes issues with onClick events combined with Draw.

@kkaefer kkaefer added touch-specific events Events that are fired when the user interacts with the map labels Jan 7, 2020
@karimnaaji karimnaaji closed this Jun 16, 2020
@karimnaaji karimnaaji reopened this Jun 17, 2020
@karimnaaji karimnaaji changed the base branch from master to main June 17, 2020 17:14
@godismyjudge95
Copy link
Copy Markdown
Author

@rdgfuentes @sdll @kjkurtz @kkaefer

I added a condition to my event pass through change and all the tests should pass now.
Let me know if there is anything else I need to do to get this merged.

@godismyjudge95
Copy link
Copy Markdown
Author

@asheemmamoowala Sorry to bring you into this, but is there any way we can get this merged into the next version? This issue has been resolved for almost a year.

TannerPerrien added a commit to DiamondSolutions/mapbox-gl-draw that referenced this pull request Aug 13, 2021
@avpeery avpeery linked an issue Sep 21, 2021 that may be closed by this pull request
@avpeery
Copy link
Copy Markdown

avpeery commented Sep 21, 2021

Hi team @asheemmamoowala @rreusser @karimnaaji @arindam1993, checking in if is there a reason this PR has not been merged? Is there something preventing this change, or a different approach that would be preferred? Thanks!

@avpeery avpeery linked an issue Sep 22, 2021 that may be closed by this pull request
@godismyjudge95
Copy link
Copy Markdown
Author

godismyjudge95 commented Oct 11, 2021

Hi team @asheemmamoowala @rreusser @karimnaaji @arindam1993, checking in if is there a reason this PR has not been merged? Is there something preventing this change, or a different approach that would be preferred? Thanks!

@avpeery Any idea if this has been reviewed by anyone authorized to merge it?

@scheepers
Copy link
Copy Markdown

Hi
Is there a solution to this? I am still getting this error and it's a blocker for the project I'm working on.

@godismyjudge95
Copy link
Copy Markdown
Author

Hi Is there a solution to this? I am still getting this error and it's a blocker for the project I'm working on.

If you want the solution asap you could manually download my repo and include it in your project. My patch still has not been merged. :/

@deen13
Copy link
Copy Markdown

deen13 commented Mar 23, 2022

We're also waiting for this. 😞

@chwallen
Copy link
Copy Markdown

chwallen commented Mar 26, 2022

@godismyjudge95 Thanks for the PR, we are using a work workaround based on this in our project. We cannot use yours directly as you check if (!target && currentModeName === 'simple_select') and assume simple_select is the default mode whereas we use a custom mode.

To make it more customizable, our version adds an additional item into the options object called passthroughTouchEventModeNames (like this which is a list (it can default to ['simple_select'] for compatibility reasons), like this:

const passthroughTouchEventModeNames = ctx.options.passthroughTouchEventModeNames || ["simple_select"];

Instead of if (!target && currentModeName === 'simple_select'), we check it using if (!target && passthroughTouchEventModeNames.some((name) => name === currentModeName)).

In case this will get merged, I would love if the mode(s) were customizable and not bound to simple_select. 😄

@SnailBones
Copy link
Copy Markdown

@chwallen Would you be interested in submitting a PR from your fork?

@rhysstubbs
Copy link
Copy Markdown

This PR has been open for 2+ years and I've just encountered this issue myself... surely somebody can answer why this hasn't been resolved yet?

@kokapelli
Copy link
Copy Markdown

kokapelli commented Jun 27, 2022

This PR has been open for 2+ years and I've just encountered this issue myself... surely somebody can answer why this hasn't been resolved yet?

Would also like to know. Not a great feeling moving away from our own drawing methods just to find out during final testing that you're forced to double the amount of map click/touch related code just to have a working MVP caused by such a minute issue.

@stepankuzmin
Copy link
Copy Markdown
Contributor

stepankuzmin commented Jan 25, 2023

Hi! I'm sorry for not getting back to you sooner. We've switched to passive event listeners instead of preventDefault here, and this should be fixed in the next release #1146

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

events Events that are fired when the user interacts with the map touch-specific

Projects

None yet