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

forcepress on iOS #1401

Closed
4 tasks done
alexreardon opened this issue Jul 11, 2019 · 3 comments
Closed
4 tasks done

forcepress on iOS #1401

alexreardon opened this issue Jul 11, 2019 · 3 comments

Comments

@alexreardon
Copy link
Collaborator

alexreardon commented Jul 11, 2019

Right now, if you call event.preventDefault() on a touchforceevent it will opt out of a lot of standard browser behaviours including clicking a scrolling.

I suspect this is a recent change in webkit, and I have raised a bug on their project. Unfortunately, we cannot just wait for them, we need to find a path forward, even if it is only temporary.

Right now it is a delicate dance to enable drag and drop interactions in force press compatible environments.

Background

Force press interactions on iOS allow for additional interactions on elements. The most notable is links prevents and navigation by applying different levels of pressure to an element

shouldRespectForcePress={false} (current default)

This allows users to disable force press interactions and allow dragging with any pressure applied.

Call event.preventDefault() for all touchforceevent events after touchstart

💥This is now breaking scrolling #1396 and clicking #1367 on iOS.

shouldRespectForcePress={true} (10.x default)

With this option we try to respect standard force press interactions as much as possible. We moved away from this as the default as people trying to drag might apply too much pressure and have their pending drag cancelled and not know why.

  • Cancel a pending if we detect a force press (touchforceevent with enough pressure)
  • If dragging and the user has not moved at all: we cancel the drag and allow the force press interaction
  • If dragging and the has moved the draggable: then we call event.preventDefault() on touchforceevents to prevent force press actions mid-drag.

Workaround

I have tried a number of potential workaround strategies. The only one that seems to be viable is this:

  • only call event.preventDefault() on touchforceevent after a force press is recognised (once enough pressure is registered). This is rather than doing it on every event
  • reduce the time to lift from 150ms to 120ms. This seems to be safely inside of the time that webkit gives for registering a force press interaction. This is not ideal as I have noticed it can interfere with slightly slower click interactions

I think this is the best path forward for now. Hopefully, webkit will action the bug I raised and we can change things back to how they were

TODO:

  • Verify workaround works and has no significant gotchas
  • Investigate webkitmouseforcechanged and if it needs the same workaround
  • Write tests
  • Backport fix from 12.x alpha to 11.x
@alexreardon
Copy link
Collaborator Author

I have shipped the workaround in an alpha for validation:

12.0.0-alpha.7

@alexreardon
Copy link
Collaborator Author

This is now mostly fixed on 11.0.5. Will we will re-enabling force press opt out for touchpads in 12.0

@alexreardon
Copy link
Collaborator Author

#1317

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

No branches or pull requests

1 participant