[iOS] Focused TextInput keeps focus and keyboard after switching pages (v9)
メンテナーはふだん 1 日以内に返信
評価
- 難易度
- 4/5
- 見積もり時間
- 1〜2日
- 初心者へのやさしさ
- 69/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- ios, react-native, swift, typescript
調査の方向性
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.
索引モデルが issue の本文から書いたものです。
説明
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.
- 主要言語
- TypeScript
- スター
- 3.4k
- フォーク
- 488
- 平均マージ
- 2日 11時間
- マージ済み PR(30日)
- 26
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
callstack/react-native-pager-view のほかの issue
-
難易度 3/5 1〜2日 初心者へのやさしさ 73/100
callstack/react-native-pager-view#1191 ·
メンテナーはふだん 1 日以内に返信
-
難易度 3/5 1〜2日 初心者へのやさしさ 58/100
callstack/react-native-pager-view#1189 ·
メンテナーはふだん 1 日以内に返信
-
iOS: PagerScrollDelegate proxies to itself and overflows the stack when the weak originalDelegate dies対応中かも @lvlrSajjad が 38 日前に担当しました。 オープン
難易度 4/5 3〜5日 初心者へのやさしさ 25/100
callstack/react-native-pager-view#1146 ·
メンテナーはふだん 1 日以内に返信
-
難易度 5/5 1週間以上 初心者へのやさしさ 35/100
callstack/react-native-pager-view#1144 · リアクション 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 4/5 3〜5日 初心者へのやさしさ 45/100
callstack/react-native-pager-view#1141 · リアクション 1 件 ·
メンテナーはふだん 1 日以内に返信
callstack/react-native-pager-view の issue をすべて見る
似ている issue
-
[BUG] rag: sentence content can cross the reported sentence boundaries対応中かも @LJK-ikun が今日担当しました。 オープンbug
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
メンテナーはふだん 1 日以内に返信
-
bug needs-triage
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
メンテナーはふだん 1 日以内に返信
-
README: the Resource URI Schemas example's file://documents/* pattern only matches that literal URIオープン
難易度 1/5 1時間未満 初心者へのやさしさ 88/100
platformatic/mcp#361 ·
メンテナーはふだん 1 日以内に返信
-
frontend
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
Push: sem service worker ou sem VAPID, o interruptor de Notificações fica ligado sem avisar nadaオープン
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
melgarafael/DeskcommCRM#3164 ·
メンテナーはふだん 1 日以内に返信