material-components-android: [Exposed Dropdown Menu] Filtering incorrectly applied after rotation
Description: It seems that in some cases filtering is incorrectly applied to AutocompleteTextView after rotating the device which causes that all options except for the selected one disappear from Dropdown Menu.
Steps to reproduce:
- Open Material Catalog app
- Go to TextField -> Exposed Dropdown Menu Demo
- Tap on 4th TextField from the top and select any value from the dropdown menu.
- Rotate the device to landscape and back to portrait
- Try to select a value from any of the 4 TextFields
The result is that those Dropdowns are now showing only 1 value instead of all of them.
Expected behavior: All TextField Dropdown Menus should show all values after device rotations
Android API version: Tested on Android 10 and Android 11 Beta
Material Library version: Checked on 1.3.0-alpha01 and 1.2.0-beta01
Device: Google Pixel 3 and Emulator
About this issue
- Original URL
- State: open
- Created 4 years ago
- Reactions: 27
- Comments: 26 (3 by maintainers)
Commits related to this issue
- Fix bug where dropdown content is lost on rotation https://github.com/material-components/material-components-android/issues/1464 — committed to jonnyandrew/synth by jonnyandrew 2 years ago
Stumbled upon this issue in our app when fragment view gets recreated from backstack or when a config change happens. We’re using
inputType="none"so filtering is not needed. The above adapter filtering solution works for me but i’ve changed the filter slightly to basically do nothing:https://user-images.githubusercontent.com/7274841/192289707-dd0ac1c7-d52a-4b2b-b1e2-8fb7329d7cb8.mp4
To solve the list filtering issue after a configuration change I set
isSaveEnabled = falsewhen instantiating the drop down menu
full code:
FIX: All the values will be visible after the device rotation and also the selected value will be displayed.
Here’s my take on this issue: Instead of creating a custom
ArrayAdapterreturning a dummy filter, which still launches a background thread to perform the filtering, I create a customAutoCompleteTextViewwhich always disables filtering when callingsetText()ifandroid:inputType="none"(including when restoring view state):I suggest to include the above code directly in
MaterialAutoCompleteTextViewto fix the issue, since the class already includes a fix to properly disable editing whenandroid:inputType="none".This solution work for me and it’s very easy to implement
I have a same bug when i back via navigation component on my fragment where i allready select some item in dropdown autoCompleteTextView.setFreezesText(false) - This not help me i am avoid bug by next trick: override fun onPause() { super.onPause() etSelectDropdown.setText(“”,false) }
Is there any update on this issue?
@consp1racy it’s reproducible using Material Catalog sample app.
Hello, as of today: 9th Dec 2021, I’m still encountering this issue in AutoCompleteTextView. Has there been any official solution??
Memory Refresh: The issue is that upon screen rotation, autoCompleteTextView drop-down only shows the selected entry instead of the multiple entries.
Any help is highly appreciated.
Can there be some updates for this? Some of the solutions don’t work for me.