Fix touch actions on iOS after entering disallowed area #3801
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.
This PR fixes an issue where if you have an open Dialog on iOS that once you interacted with an area otuside of the dialog, you could no longer scroll or zoom the dialog itself anymore until it closed and reopened.
The reason this was happening is that on
touchstart
we checked whether we are in an allowed area or not.overscroll-behavior: contain
to the scrollable area to prevent scrolling the body behind it.touch-action: none
to the element you were touching to prevent any other touch events from being fired.The problem with this is that we never reset the state until the dialog is closed (and eventually unmounted).
So to solve the problem, every time we get a
touchstart
event, we reset those CSS properties to their previous values, and then check again whether we are in an allowed area or not.Note: the
touchstart
event listener is set on the document itself, so we still get the event even iftouch-action: none
was set on the target element.Test plan
Made 2 videos with a before / after comparison. The reproduction used is from #3234. The steps I'm applying here are:
Before:
bad.mp4
After:
good.mp4
Fixes: #3234
Closes: #3602