Change theme
Help
Press space for more information.
Show links for this issue (Shortcut: i, l)
Copy issue ID
Previous Issue (Shortcut: k)
Next Issue (Shortcut: j)
Sign in to use full features.
Vote: I am impacted
Notification menu
Refresh (Shortcut: Shift+r)
Go home (Shortcut: u)
Pending code changes (auto-populated)
View issue level access limits(Press Alt + Right arrow for more information)
Attachment actions
Unintended behavior
View staffing
Description
Component used:'androidx.viewpager2:viewpager2:1.1.0-alpha01' Devices/Android versions reproduced on: Several, reliably on OnePlus 8 Pro
If this is a bug in the library, we would appreciate if you could attach:
My app has multiple tabs with individual Fragments and associated EditText objects, I am using ViewPager2 to scroll through the different fragments.
From a users perspective the issue is that whenever a user scrolls to another tab and tries to enter or delete data into an EditText the EditText will immediately lose focus. After the EditText is manually re-selected data entry works as expected.
From an application point of view I traced the loss of focus down to the fact that for some reason ScrollEventAdapter.onScrolled get's called with mAdapterState = STATE_IDLE (0) the moment a character is entered or deleted.
Which according to the comments in ScrollEventAdapter.java fires the onPageSelected event which ultimately leads to the loss of focus:
I can see that ScrollEventAdapter.onScrolled get's called when flipping through my tabs, but always with mAdapterState > 0.
Steps to reproduce:
The screenshot attached shows the situation right after the first digit "1" got entered. The EditText object lost focus and the first ViewPager2 tab got selected.
What makes things even more complicated is that this error occurs 100% on my personal phone (OnePlus 8Pro), fails 8 out of 10 times with the various OS and language versions I use to test in emulators and fails to an unknown extend with my users.
So I guess the bug/question is why is ViewPager2.onScrolled fired the moment I enter/delete a value in the EditText?
I started this topic on StackOverflowhttps://stackoverflow.com/questions/67344003/edittext-loses-focus-after-first-digit-is-entered but given that I got 0 response I think I might be dealing with a bug rather than a mistake at my end.
Source code and additional screenshots of the app / the tabs and their EditText objects can be found here:https://gitlab.com/toz12/medilog
Happy to provide any additional information required.