[iOS] Focused TextInput keeps focus and keyboard after switching pages (v9)
Los mantenedores suelen responder en 1 día
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 1-2 días
- Aptitud para principiantes
- 69/100
- Tipo de issue
- Error
- Claridad
- Bien especificado
- Estado de actividad
- Activo
- Stack tecnológico
- ios, react-native, swift, typescript
Línea de trabajo
Start at the iOS PagerViewProvider path that forwards onPageSelected and inspect how it handles focus when the selected page changes. Compare with the Android fix in #1155, which clears focus outside the selected page and hides the keyboard. Reproduce with the provided two-page TextInput example using setPage and a swipe; done when leaving a page blurs its input and the keyboard follows.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Environment
- react-native-pager-view: 9.0.9 (also present in 9.0.8)
- React Native: 0.88, New Architecture
- Xcode 27, iOS 27.0 simulator (iPhone 18 Pro)
- iOS only. The Android half of this was fixed in #1155 and shipped in 9.0.8.
Description
This is the iOS half of #1154, which was fixed for Android only.
A TextInput that's focused on one page stays focused after you switch to another page, whether with setPage or a swipe. The keyboard stays open, nothing on the page you land on is focused, and typing still goes into the input that's now off-screen, so the user edits a field they can't see.
The iOS implementation never touches focus. PagerViewProvider forwards onPageSelected and leaves the first responder alone, and SwiftUI's paged TabView keeps the neighbouring pages in the view hierarchy, so the input that was left behind holds the first responder and the keyboard with it.
keyboardDismissMode doesn't cover this. It defaults to none, and even on-drag only reacts to a drag, so setPage never dismisses. Dismissing the keyboard is also not the same as blurring, which is what leaves keystrokes going into the off-screen field.
Android behaved the same way until #1155, which clears focus held outside the selected page when a page is selected, and hides the keyboard explicitly. The two platforms disagree today: the same code blurs on Android 9.0.8 and keeps focus on iOS.
Expected: leaving a page blurs an input focused on it and the keyboard follows, as it now does on Android.
Actual: the input keeps focus, the keyboard stays open, and keystrokes go to the off-screen page.
Here is the moment it goes wrong, with a status line showing the selected page, the focused input and the keyboard: the pager is on page 0, while page 1's input still holds focus and the keyboard.
Found in Expensify/App#101157, where a pager hosts a form on each tab.
Reproducible Demo
import { useRef } from 'react';
import { Button, StyleSheet, TextInput, View } from 'react-native';
import PagerView from 'react-native-pager-view';
export function Repro() {
const ref = useRef<PagerView>(null);
return (
<PagerView ref={ref} style={StyleSheet.absoluteFill} initialPage={0}>
{[0, 1].map((page) => (
<View key={page} style={{ flex: 1, padding: 24, gap: 12 }}>
<TextInput placeholder={`Input ${page}`} style={{ borderWidth: 1, padding: 12 }} />
<Button title={`Go to page ${1 - page}`} onPress={() => ref.current?.setPage(1 - page)} />
</View>
))}
</PagerView>
);
}
- Focus
Input 1on page 1 and wait for the keyboard. - Tap Go to page 0, or swipe back to page 0.
- Type.
The keyboard never closes, and the characters land in Input 1 while page 0 is on screen. Swipe back and you'll find the text in the input you couldn't see.
- Lenguaje dominante
- TypeScript
- Estrellas
- 3.4k
- Forks
- 485
- Merge medio
- 2 d 11 h
- PR fusionados (30 d)
- 26
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de callstack/react-native-pager-view
-
Dificultad 3/5 1-2 días Aptitud para principiantes 73/100
callstack/react-native-pager-view#1191 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 3/5 1-2 días Aptitud para principiantes 58/100
callstack/react-native-pager-view#1189 ·
Los mantenedores suelen responder en 1 día
-
iOS: PagerScrollDelegate proxies to itself and overflows the stack when the weak originalDelegate diesPosiblemente ocupada @lvlrSajjad la tomó hace 37 días. Abierto
Dificultad 4/5 3-5 días Aptitud para principiantes 25/100
callstack/react-native-pager-view#1146 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 5/5 Más de una semana Aptitud para principiantes 35/100
callstack/react-native-pager-view#1144 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 4/5 3-5 días Aptitud para principiantes 45/100
callstack/react-native-pager-view#1141 · 1 reacción ·
Los mantenedores suelen responder en 1 día
Todos los issues de callstack/react-native-pager-view
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 66/100
getsentry/sentry-conventions#732 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
status:in-linear status:team-assigned team:nodes
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
n8n-io/n8n#41548 · 2 comentarios ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
motiondivision/motion#3955 ·
Los mantenedores suelen responder en 1 día
-
DQ assisgnment closing at CRAbiertoenhancement
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
equinor/prisma-decision-web#919 ·
Los mantenedores suelen responder en 1 día
-
自荐 / Suggestion: Prisma ComputeAbierto
Dificultad 1/5 Menos de una hora Aptitud para principiantes 83/100