Repository navigation
fix(android): don't tint the whole pager when it takes keyboard focus - #1152
Conversation
|
Hello 👋 |
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
The focused, API-gated change directly addresses the documented Android behavior without altering keyboard navigation.
Review effort: Balanced
Findings: None
What changed in this PR
Disables Android’s default focus highlight on ViewPager2’s internal RecyclerView to prevent whole-page tinting after keyboard focus changes.
Changes:
- Adds an API 26+ guard.
- Disables the RecyclerView’s default focus highlight without changing focus behavior.
| File | Description |
|---|---|
android/src/main/java/com/reactnativepagerview/PagerViewViewManager.kt |
Applies the Android focus-highlight fix during pager creation. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
oh sorry, don't know why claude opened it for non-master branch, I was testing it on the latest package version. |
|
Closing: we moved to v9, which does not have this bug. |
|
I will reopen that and merge it for 8.x version in my free time |
After a hardware key takes the window out of touch mode, a TextInput that blurs hands focus to ViewPager2's internal RecyclerView. It has no focused-state drawable, so Android 8+ draws its default focus highlight over every page. Disable that highlight; the RecyclerView stays focusable and page children keep their own highlight.
560f0b4 to
3739446
Compare
Summary
Fixes #1151.
On Android 8+, after a
TextInputinside aPagerViewblurs while a hardware keyboard is in use, Android gives focus to ViewPager2's internalRecyclerViewand draws its default focus highlight over every page. The result is a grey tint (about 7.5 % black) that stays until another view takes focus.This PR turns off the default focus highlight on that
RecyclerView(API 26+). The view stays focusable, so keyboard navigation does not change, and page children keep their own focus highlight.Impact: Android only,
PagerViewViewManager.createViewInstance(one import and three lines of code).Test Plan
What's required for testing (prerequisites)?
An Android 8+ emulator (its host keyboard is a hardware keyboard) or a device with a hardware keyboard, and a
PagerViewpage with aTextInput(snippet in #1151).What are the steps to reproduce (after prerequisites)?
TextInput, type with the hardware keyboard, then press Enter. With adb:adb shell input text hello, thenadb shell input keyevent KEYCODE_ENTER.adb shell dumpsys window | grep mInTouchModeprintsmInTouchMode=false.RecyclerViewstill takes focus, so only the highlight changes.We verified this exact change in our app as a patch on 8.0.4 (React Native 0.81.5, New Architecture, Android 17 emulator). After Enter, the page keeps its colors (
#FBF6F0background,#FFFFFFfield). Before the change they were#E8E4DEand#ECECEC. We did not build this repo's example app.Compatibility
Checklist
README.md(not needed)🤖 Generated with Claude Code