@@ -139,24 +139,7 @@ function preventScrollMobileSafari() {
139
139
}
140
140
} ;
141
141
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 = ( ) => {
160
143
if ( restoreScrollableStyles ) {
161
144
restoreScrollableStyles ( ) ;
162
145
}
@@ -167,10 +150,8 @@ function preventScrollMobileSafari() {
167
150
if ( willOpenKeyboard ( target ) ) {
168
151
setupStyles ( ) ;
169
152
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.
174
155
target . style . transform = 'translateY(-2000px)' ;
175
156
requestAnimationFrame ( ( ) => {
176
157
target . style . transform = '' ;
0 commit comments