Skip to content

Commit 47d4b4f

Browse files
committed
Don’t cancel touchmove on input elements inside a dialog (#3166)
* Don’t cancel touchmove on `input` elements inside a dialog * Update changelog * Update # Conflicts: # packages/@headlessui-react/CHANGELOG.md
1 parent 7ebeaab commit 47d4b4f

File tree

4 files changed

+19
-1
lines changed

4 files changed

+19
-1
lines changed

packages/@headlessui-react/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1212
- Add `immediate` prop to `<Combobox />` for immediately opening the Combobox when the `input` receives focus ([#2686](https://github.com/tailwindlabs/headlessui/pull/2686))
1313
- Add `virtual` prop to `Combobox` component ([#2779](https://github.com/tailwindlabs/headlessui/pull/2779))
1414

15+
### Fixed
16+
17+
- Don’t cancel `touchmove` on `input` elements inside a dialog ([#3166](https://github.com/tailwindlabs/headlessui/pull/3166))
18+
1519
## [1.7.19] - 2024-04-15
1620

1721
### Fixed

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/CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10-
- Nothing yet!
10+
### Fixed
11+
12+
- Don’t cancel `touchmove` on `input` elements inside a dialog ([#3166](https://github.com/tailwindlabs/headlessui/pull/3166))
1113

1214
## [1.7.21] - 2024-04-26
1315

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)