Don’t cancel touchmove on input elements inside a dialog (#3166)

* Don’t cancel touchmove on `input` elements inside a dialog

* Update changelog

* Update
This commit is contained in:
Jordan Pittman
2024-05-03 10:35:50 -04:00
committed by GitHub
parent a45cb6ff6a
commit d416c1ca59
3 changed files with 13 additions and 0 deletions
+1
View File
@@ -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))
- Dont cancel `touchmove` on `input` elements inside a dialog ([#3166](https://github.com/tailwindlabs/headlessui/pull/3166))
### Changed
@@ -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.
@@ -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.