Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/@headlessui-react/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Ensure sibling `Dialog` components are scrollable on mobile ([#3796](https://github.com/tailwindlabs/headlessui/pull/3796))
- Infer `Combobox` type based on `onChange` handler ([#3798](https://github.com/tailwindlabs/headlessui/pull/3798))
- Allow home/end key default behavior inside `ComboboxInput` when `Combobox` is closed ([#3798](https://github.com/tailwindlabs/headlessui/pull/3798))
- Ensure interacting with a `Dialog` on iOS works after interacting with a disallowed area ([#3801](https://github.com/tailwindlabs/headlessui/pull/3801))

## [2.2.8] - 2025-09-12

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,23 +76,27 @@ export function handleIOSLocking(): ScrollLockStep<ContainerMetadata> {
)

// Rely on overscrollBehavior to prevent scrolling outside of the Dialog.
d.addEventListener(doc, 'touchstart', (e) => {
if (DOM.isHTMLorSVGElement(e.target) && DOM.hasInlineStyle(e.target)) {
if (inAllowedContainer(e.target)) {
// Find the root of the allowed containers
let rootContainer = e.target
while (
rootContainer.parentElement &&
inAllowedContainer(rootContainer.parentElement)
) {
rootContainer = rootContainer.parentElement!
}
d.group((_d) => {
d.addEventListener(doc, 'touchstart', (e) => {
_d.dispose()
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you look at this change with ?w=1 then the only real code that changed here is that we wrap everything in a d.group so we have a new set of disposables to work with.

Every time a touchstart event fires, we dispose the local set of disposables and start over.

This is a local set of disposables so we don't dispose any other styles that were set or event listeners that should still listen for events.


if (DOM.isHTMLorSVGElement(e.target) && DOM.hasInlineStyle(e.target)) {
if (inAllowedContainer(e.target)) {
// Find the root of the allowed containers
let rootContainer = e.target
while (
rootContainer.parentElement &&
inAllowedContainer(rootContainer.parentElement)
) {
rootContainer = rootContainer.parentElement!
}

d.style(rootContainer, 'overscrollBehavior', 'contain')
} else {
d.style(e.target, 'touchAction', 'none')
_d.style(rootContainer, 'overscrollBehavior', 'contain')
} else {
_d.style(e.target, 'touchAction', 'none')
}
}
}
})
})

d.addEventListener(
Expand Down