Skip to content

Commit d416c1c

Browse files
Don’t cancel touchmove on input elements inside a dialog (#3166)
* Don’t cancel touchmove on `input` elements inside a dialog * Update changelog * Update
1 parent a45cb6f commit d416c1c

File tree

3 files changed

+13
-0
lines changed

3 files changed

+13
-0
lines changed

packages/@headlessui-react/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
3939
- Fix enter transitions in `Transition` component ([#3074](https://github.com/tailwindlabs/headlessui/pull/3074))
4040
- Fix focus handling in `ListboxOptions` and `MenuItems` components ([#3112](https://github.com/tailwindlabs/headlessui/pull/3112))
4141
- Fix horizontal scrolling inside the `Dialog` component ([#2889](https://github.com/tailwindlabs/headlessui/pull/2889))
42+
- Don’t cancel `touchmove` on `input` elements inside a dialog ([#3166](https://github.com/tailwindlabs/headlessui/pull/3166))
4243

4344
### Changed
4445

packages/@headlessui-react/src/hooks/document-overflow/handle-ios-locking.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,12 @@ export function handleIOSLocking(): ScrollLockStep<ContainerMetadata> {
9494
(e) => {
9595
// Check if we are scrolling inside any of the allowed containers, if not let's cancel the event!
9696
if (e.target instanceof HTMLElement) {
97+
// Some inputs like `<input type=range>` use touch events to
98+
// allow interaction. We should not prevent this event.
99+
if (e.target.tagName === 'INPUT') {
100+
return
101+
}
102+
97103
if (inAllowedContainer(e.target as HTMLElement)) {
98104
// Even if we are in an allowed container, on iOS the main page can still scroll, we
99105
// have to make sure that we `event.preventDefault()` this event to prevent that.

packages/@headlessui-vue/src/hooks/document-overflow/handle-ios-locking.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,12 @@ export function handleIOSLocking(): ScrollLockStep<ContainerMetadata> {
9494
(e) => {
9595
// Check if we are scrolling inside any of the allowed containers, if not let's cancel the event!
9696
if (e.target instanceof HTMLElement) {
97+
// Some inputs like `<input type=range>` use touch events to
98+
// allow interaction. We should not prevent this event.
99+
if (e.target.tagName === 'INPUT') {
100+
return
101+
}
102+
97103
if (inAllowedContainer(e.target as HTMLElement)) {
98104
// Even if we are in an allowed container, on iOS the main page can still scroll, we
99105
// have to make sure that we `event.preventDefault()` this event to prevent that.

0 commit comments

Comments
 (0)