You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fix touch actions on iOS after entering disallowed area (#3801)
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.
- If we are in an allowed area, add `overscroll-behavior: contain` to
the scrollable area to prevent scrolling the body behind it.
- If we are not in an allowed area, add `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 if `touch-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:
1. Open the dialog by tapping on the toggle button
2. Scroll inside the dialog
3. Pinch to zoom inside the dialog
4. Tap outside / scroll outside the dialog to show that you can't with
the outside
5. Scroll inside the dialog again
6. Pinch to zoom inside the dialog again
**Before:**
1. ✅ Open the dialog by tapping on the toggle button
2. ✅ Scroll inside the dialog
3. ✅ Pinch to zoom inside the dialog
4. ✅ Tap outside / scroll outside the dialog to show that you can't with
the outside
5. ❌ Scroll inside the dialog again
6. ❌ Pinch to zoom inside the dialog again
https://github.com/user-attachments/assets/d79d9794-3732-4201-a4c9-43ea36d302ce
**After:**
1. ✅ Open the dialog by tapping on the toggle button
2. ✅ Scroll inside the dialog
3. ✅ Pinch to zoom inside the dialog
4. ✅ Tap outside / scroll outside the dialog to show that you can't with
the outside
5. ✅ Scroll inside the dialog again
6. ✅ Pinch to zoom inside the dialog again
https://github.com/user-attachments/assets/f6c1c765-3c8c-4d3c-91c2-1b43507f6434Fixes: #3234Closes: #3602
Copy file name to clipboardExpand all lines: packages/@headlessui-react/CHANGELOG.md
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
14
14
- Ensure sibling `Dialog` components are scrollable on mobile ([#3796](https://github.com/tailwindlabs/headlessui/pull/3796))
15
15
- Infer `Combobox` type based on `onChange` handler ([#3798](https://github.com/tailwindlabs/headlessui/pull/3798))
16
16
- Allow home/end key default behavior inside `ComboboxInput` when `Combobox` is closed ([#3798](https://github.com/tailwindlabs/headlessui/pull/3798))
17
+
- Ensure interacting with a `Dialog` on iOS works after interacting with a disallowed area ([#3801](https://github.com/tailwindlabs/headlessui/pull/3801))
0 commit comments