[iOS] UIKit's scroll to a focused field can leave the pager between pages

Abierto
#1,230 4 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

@TaduJR ya está trabajando en esto.

Desde el 6/11/2026.

  • #1234 de @TaduJR — abierto

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
52/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
ios, react-native, typescript
Área
frontend, mobile

Línea de trabajo

Start with the example app screen “Issue #1154 Page Change Focus Repro” and set styles.events to height: 44 to reproduce the timing. Trace the iOS pager handling of interrupted setPage calls alongside the focus and keyboard events, then run the described release-build sequence. Done means the pager settles on page 2, reports matching selection and scroll state, and the focused input and keyboard behave consistently.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

Environment

  • react-native-pager-view: main
  • React Native 0.88.0, new architecture
  • iPhone 18 Pro simulator, iOS 27.0, release build

Description

When a text field on another page takes focus, UIKit scrolls the pager's collection view to reveal it: scrollRectToVisible, twice and animated, once while the field becomes first responder and once from the keyboard notification. That scroll replaces the slide TabView is running and stops at the smallest offset that shows the field, and UIKit leaves the pager there.

The selection and the screen then disagree. onPageSelected reports page 2 while the pager rests nearest page 1, the log reads selected 2 and then state idle at 1, and the screen shows a sliver of page 0 beside page 1. Because the pager is not on a page boundary nothing reports a rest, so the input on the page being left keeps focus with the keyboard open.

Measuring the collection view's offset at scrollViewDidEndScrollingAnimation, against a 402 pt page:

run end offset
interrupt, with the arriving page's input focused in the same handler 377
interrupt, no focus 804
interrupt, keyboard already open from the previous page 804
focus on arrival, single setPage, no interrupt 402

Both ingredients are needed, and 377 is not arbitrary: it is the least the pager can scroll to bring that field on screen.

A per-instance override is viable, since PagerGestureObserver.installGestureArbitration already gives the pager's collection view its own runtime subclass. It is a behaviour change: an app that focuses an input on a page it is not showing would see nothing move, where today the pager is dragged between pages instead. An enclosing scroll view is unaffected, since in a pager inside a ScrollView inside a KeyboardAvoidingView the pager receives no reveal at all in 6 of 6 runs, and every one goes to the outer scroll view and the field's own editor.

Reproducible Demo

The example app has the screen already: Issue #1154 Page Change Focus Repro. Its event log reflows as it grows, which shifts the timing, so give the events box a fixed height first (height: 44 on styles.events) to see this reliably.

  1. Open the screen in a release build
  2. Tap onPress, so the arriving page's input is focused in the same handler as the command
  3. Tap the input on page 0, so the keyboard opens
  4. Tap Go 1 then 2, which sends setPage(1) and then setPage(2) from onPageSelected
  5. The pager stops between pages and stays there. The status line reads Selected: 2, the log ends state idle at 1, and the input on page 1 is still focused with the keyboard open

With that fixed height, two runs in six end this way on main. Without it the screen's own timing hides it most of the time, though the same case failed CI on #1224 with Selected: 1 | Focused: input 1 | Keyboard: visible | Scrolls: 9.

A fix is open as #1234, which declines the reveal from iOS 16 rather than repairing the landing after it.

Lenguaje dominante
TypeScript
Estrellas
3.4k
Forks
491
Merge medio
2 d 4 h
PR fusionados (30 d)
51

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de callstack/react-native-pager-view

Todos los issues de callstack/react-native-pager-view

Issues similares

Más issues de TypeScript

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.