Skip to content

Commit a89b7c8

Browse files
authored
fix: Remove onTouchEnd handler in iOS usePreventScroll (#7479)
1 parent b37f279 commit a89b7c8

File tree

1 file changed

+3
-22
lines changed

1 file changed

+3
-22
lines changed

packages/@react-aria/overlays/src/usePreventScroll.ts

Lines changed: 3 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -139,24 +139,7 @@ function preventScrollMobileSafari() {
139139
}
140140
};
141141

142-
let onTouchEnd = (e: TouchEvent) => {
143-
let target = e.target as HTMLElement;
144-
145-
// Apply this change if we're not already focused on the target element
146-
if (willOpenKeyboard(target) && target !== document.activeElement) {
147-
e.preventDefault();
148-
setupStyles();
149-
150-
// Apply a transform to trick Safari into thinking the input is at the top of the page
151-
// so it doesn't try to scroll it into view. When tapping on an input, this needs to
152-
// be done before the "focus" event, so we have to focus the element ourselves.
153-
target.style.transform = 'translateY(-2000px)';
154-
target.focus();
155-
requestAnimationFrame(() => {
156-
target.style.transform = '';
157-
});
158-
}
159-
142+
let onTouchEnd = () => {
160143
if (restoreScrollableStyles) {
161144
restoreScrollableStyles();
162145
}
@@ -167,10 +150,8 @@ function preventScrollMobileSafari() {
167150
if (willOpenKeyboard(target)) {
168151
setupStyles();
169152

170-
// Transform also needs to be applied in the focus event in cases where focus moves
171-
// other than tapping on an input directly, e.g. the next/previous buttons in the
172-
// software keyboard. In these cases, it seems applying the transform in the focus event
173-
// is good enough, whereas when tapping an input, it must be done before the focus event. 🤷‍♂️
153+
// Apply a transform to trick Safari into thinking the input is at the top of the page
154+
// so it doesn't try to scroll it into view.
174155
target.style.transform = 'translateY(-2000px)';
175156
requestAnimationFrame(() => {
176157
target.style.transform = '';

0 commit comments

Comments
 (0)