Skip to content

[TextInputLayout] Errors are hidden when Layout is disabled #3550

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,7 @@ public interface LengthCounter {

@Nullable private Drawable startDummyDrawable;
private int startDummyDrawableWidth;
private CharSequence disabledErrorText;

/**
* Values for the end icon mode.
Expand Down Expand Up @@ -2139,6 +2140,13 @@ public void setError(@Nullable final CharSequence errorText) {
setErrorEnabled(true);
}

// If the layout is disabled,
// save the error to display it when the layout is enabled
if (!isEnabled()) {
disabledErrorText = errorText;
return;
}

if (!TextUtils.isEmpty(errorText)) {
indicatorViewController.showError(errorText);
} else {
Expand Down Expand Up @@ -2763,6 +2771,15 @@ public void setEnabled(boolean enabled) {
// drawable state
recursiveSetEnabled(this, enabled);
super.setEnabled(enabled);

if (!enabled) {
disabledErrorText = getError();
if (!TextUtils.isEmpty(disabledErrorText)) {
indicatorViewController.hideError();
}
} else if (!TextUtils.isEmpty(disabledErrorText) && isErrorEnabled()) {
setError(disabledErrorText);
}
}

private static void recursiveSetEnabled(@NonNull final ViewGroup vg, final boolean enabled) {
Expand Down