-
Notifications
You must be signed in to change notification settings - Fork 3.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Exposed Dropdown Menu] Filtering incorrectly applied after rotation #1464
Comments
Hi, you'll want to include a small project that reproduces the issue. |
@consp1racy it's reproducible using Material Catalog sample app. |
This is because |
I workaround it by overriding public class ExposedDropdownMenu extends MaterialAutoCompleteTextView {
public ExposedDropDown(@NonNull final Context context, @Nullable final AttributeSet attributeSet) {
super(context, attributeSet);
}
@Override
public boolean getFreezesText() {
return false;
}
} |
I have the same issue :( I tried calling |
same problem here, hoping for a fix in the next version 👍 |
I have a same bug when i back via navigation component on my fragment where i allready select some item in dropdown |
FIX: All the values will be visible after the device rotation and also the selected value will be displayed. public class TextInputDropDownMenu extends AppCompatAutoCompleteTextView {
public TextInputDropDownMenu(@NonNull Context context) {
super(context);
}
public TextInputDropDownMenu(@NonNull Context context, @Nullable AttributeSet attrs) {
super(context, attrs);
}
public TextInputDropDownMenu(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
}
{
setInputType(InputType.TYPE_NULL);
}
@Override
public boolean getFreezesText() {
return false;
}
@Override
public Parcelable onSaveInstanceState() {
Parcelable parcelable = super.onSaveInstanceState();
if (TextUtils.isEmpty(getText())) {
return parcelable;
}
CustomSavedState customSavedState = new CustomSavedState(parcelable);
customSavedState.text = getText().toString();
return customSavedState;
}
@Override
public void onRestoreInstanceState(Parcelable state) {
if (!(state instanceof CustomSavedState)) {
super.onRestoreInstanceState(state);
return;
}
CustomSavedState customSavedState = (CustomSavedState) state;
setText(customSavedState.text, false);
super.onRestoreInstanceState(customSavedState.getSuperState());
}
private static final class CustomSavedState extends BaseSavedState {
private String text;
public CustomSavedState(Parcelable superState) {
super(superState);
}
public CustomSavedState(Parcel source) {
super(source);
text = source.readString();
}
@Override
public void writeToParcel(Parcel out, int flags) {
super.writeToParcel(out, flags);
out.writeString(text);
}
private static final Creator<CustomSavedState> CREATOR = new Creator<CustomSavedState>() {
@Override
public CustomSavedState createFromParcel(Parcel source) {
return new CustomSavedState(source);
}
@Override
public CustomSavedState[] newArray(int size) {
return new CustomSavedState[size];
}
};
}
} |
Thanks , It helps me a lot. |
@ar-arvind
|
are there any updates on this issue? |
Is there any update on this issue? |
Is there any update on this issue ? |
For a simple pick list the following seems to work -- define a new In Korlin it is used as follows:
It also allows you to skip the
The never filter adapter is a trivial extension to
|
Can there be some updates for this? Some of the solutions don't work for me. |
For me too, the solutions specified in this issue do not work. It would be nice to have this annoying issue closed. |
Stumbled upon this issue in our app when fragment view gets recreated from backstack or when a config change happens. We're using
|
This solution work for me and it's very easy to implement |
Here's my take on this issue:
I suggest to include the above code directly in |
Hello, as of today: 9th Dec 2021, I'm still encountering this issue in AutoCompleteTextView. 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. |
…ger filtering at numOfPeople Exposed Dropdown (material-components/material-components-android#1464)
This is still issue , why you closed it without fixing bug ? |
I closed #2171 as a duplicate. : ) |
It works perfect, Thanks,
|
Record_2022-09-26-15-28-59.mp4To solve the list filtering issue after a configuration change I set
when instantiating the drop down menu full code:
|
None of above worked - in my case it randomly failed when put on recyclerview with dynamic adding/removing of item. Found workaround though (C#)
|
This is a easy workaround (#4506).
or
or
or
or
|
I also reported this to the Issue Tracker: https://issuetracker.google.com/issues/322066510 |
Since there is no progress, I created pull requests (androidx/androidx#704, #4335, and #4506). |
Kotlin version. Use this instead of calling import android.content.Context
import android.os.Parcelable
import android.util.AttributeSet
import com.google.android.material.textfield.MaterialAutoCompleteTextView
class MaterialAutoCompleteTextViewPatch @JvmOverloads constructor(
context: Context,
attrs: AttributeSet? = null,
defStyleAttr: Int = com.google.android.material.R.attr.autoCompleteTextViewStyle
) : MaterialAutoCompleteTextView(context, attrs, defStyleAttr) {
override fun onRestoreInstanceState(state: Parcelable) {
val threshold = getThreshold()
// Make filter invalid temporarily
setThreshold(Integer.MAX_VALUE)
super.onRestoreInstanceState(state)
setThreshold(threshold)
}
} |
can be simplified: import android.content.Context
import android.os.Parcelable
import android.util.AttributeSet
import com.google.android.material.textfield.MaterialAutoCompleteTextView
class MaterialAutoCompleteTextViewPatch @JvmOverloads constructor(
context: Context,
attrs: AttributeSet? = null,
defStyleAttr: Int = R.attr.autoCompleteTextViewStyle
) : MaterialAutoCompleteTextView(context, attrs, defStyleAttr) {
override fun onRestoreInstanceState(state: Parcelable) {
val tmp = threshold
// Make filter invalid temporarily
threshold = Integer.MAX_VALUE
super.onRestoreInstanceState(state)
threshold = tmp
}
} |
…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:
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
The text was updated successfully, but these errors were encountered: