Skip to content

Commit

Permalink
Don’t cancel touchmove on input elements inside a dialog (#3166)
Browse files Browse the repository at this point in the history
* Don’t cancel touchmove on `input` elements inside a dialog

* Update changelog

* Update
  • Loading branch information
thecrypticace authored May 3, 2024
1 parent a45cb6f commit d416c1c
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions packages/@headlessui-react/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Fix enter transitions in `Transition` component ([#3074](https://github.com/tailwindlabs/headlessui/pull/3074))
- Fix focus handling in `ListboxOptions` and `MenuItems` components ([#3112](https://github.com/tailwindlabs/headlessui/pull/3112))
- Fix horizontal scrolling inside the `Dialog` component ([#2889](https://github.com/tailwindlabs/headlessui/pull/2889))
- Don’t cancel `touchmove` on `input` elements inside a dialog ([#3166](https://github.com/tailwindlabs/headlessui/pull/3166))

### Changed

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,12 @@ export function handleIOSLocking(): ScrollLockStep<ContainerMetadata> {
(e) => {
// Check if we are scrolling inside any of the allowed containers, if not let's cancel the event!
if (e.target instanceof HTMLElement) {
// Some inputs like `<input type=range>` use touch events to
// allow interaction. We should not prevent this event.
if (e.target.tagName === 'INPUT') {
return
}

if (inAllowedContainer(e.target as HTMLElement)) {
// Even if we are in an allowed container, on iOS the main page can still scroll, we
// have to make sure that we `event.preventDefault()` this event to prevent that.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,12 @@ export function handleIOSLocking(): ScrollLockStep<ContainerMetadata> {
(e) => {
// Check if we are scrolling inside any of the allowed containers, if not let's cancel the event!
if (e.target instanceof HTMLElement) {
// Some inputs like `<input type=range>` use touch events to
// allow interaction. We should not prevent this event.
if (e.target.tagName === 'INPUT') {
return
}

if (inAllowedContainer(e.target as HTMLElement)) {
// Even if we are in an allowed container, on iOS the main page can still scroll, we
// have to make sure that we `event.preventDefault()` this event to prevent that.
Expand Down

0 comments on commit d416c1c

Please sign in to comment.