Skip to content
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

Error icon and password icon overlapping #1444

Closed
wahdatjan opened this issue Jun 26, 2020 · 9 comments
Closed

Error icon and password icon overlapping #1444

wahdatjan opened this issue Jun 26, 2020 · 9 comments
Assignees
Labels

Comments

@wahdatjan
Copy link

Overlapping of error icon and show password icon .When both are visible.

image

@wahdatjan wahdatjan added the bug label Jun 26, 2020
@leticiarossi
Copy link
Contributor

Can you provide your source code?

@wahdatjan
Copy link
Author

yes here it is
`
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/register_root"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_marginBottom="8dp"
android:layout_marginEnd="24dp"
android:layout_marginStart="24dp"
android:layout_marginTop="8dp"
xmlns:android="http://schemas.android.com/apk/res/android">

<com.google.android.material.textfield.TextInputLayout
    android:id="@+id/textInputEmail"
    style="@style/parent"
    android:layout_marginTop="@dimen/loginViewsMargin"
    app:layout_constraintLeft_toLeftOf="parent"
    app:layout_constraintRight_toRightOf="parent"
    app:layout_constraintTop_toBottomOf="@id/login_label"
    >

    <com.google.android.material.textfield.TextInputEditText
        android:id="@+id/editTextEmail"
        style="@style/modifiedEditText"
        android:hint="@string/login_email_hint"
        android:textSize="@dimen/editTextTextSize"
        android:inputType="textEmailAddress"
        android:maxLines="1" />
</com.google.android.material.textfield.TextInputLayout>


<com.google.android.material.textfield.TextInputLayout
    android:id="@+id/textInputPassword"
    style="@style/parent"
    app:passwordToggleEnabled="true"
    android:layout_marginTop="@dimen/loginViewsMargin"
    app:layout_constraintLeft_toLeftOf="parent"
    app:layout_constraintRight_toRightOf="parent"
    app:layout_constraintTop_toBottomOf="@id/textInputEmail"
    >

    <com.google.android.material.textfield.TextInputEditText
        android:id="@+id/editTextPassword"
        style="@style/modifiedEditText"
        android:hint="@string/login_password_hint"
        android:textSize="@dimen/editTextTextSize"
        android:inputType="textPassword"
        android:maxLines="1" />
</com.google.android.material.textfield.TextInputLayout>

<Button
    android:id="@+id/login_button"
    style="@style/loginButton"
    android:text="Login"
    android:layout_marginTop="@dimen/loginViewsMargin"
    app:layout_constraintRight_toRightOf="parent"
    app:layout_constraintTop_toBottomOf="@id/textInputPassword"

    />

<TextView
    android:id="@+id/signUpLink"
    style="@style/parent"
    android:textAlignment="textEnd"
    android:textStyle="bold"
    android:textColor="@color/primaryTextColor"
    android:text="New User? SignUp here "
    android:layout_marginTop="10dp"
    app:layout_constraintRight_toRightOf="parent"
    app:layout_constraintTop_toBottomOf="@id/login_button"
    app:layout_constraintLeft_toLeftOf="parent"
    />

</androidx.constraintlayout.widget.ConstraintLayout>`

@msfjarvis
Copy link

msfjarvis commented Jun 27, 2020

Not sure if that's what the OP did, but in my case this issue was triggered because of Kotlin converting setError to its property syntax. That caused things to be delegated to platform TextView's setError(String) method as opposed to TextInputEditText's setError(String, Drawable). I believe the fix here from the MDC side would be to just override setError(String) and call setError(String, getDrawable(R.drawable.mtrl_ic_error)) for users.

Edit: Here's the commit showing the change that resolved this for me https://msfjarvis.dev/aps/317eb00fa358

@LaurieScheepers
Copy link

The workaround in your commit causes the error icon to disappear on my side.

@msfjarvis
Copy link

The workaround in your commit causes the error icon to disappear on my side.

You're right, I was doing more than one thing wrong. Properly fixed here: https://msfjarvis.dev/aps/3c0665d33133

@LaurieScheepers
Copy link

Your updated solution still causes the error icon to disappear as you are setting the error on the input layout, not the edit text. Doing it your way causes the visibility icon to show, but the error icon and tooltip goes away, which is the functionality I'm after.

@msfjarvis
Copy link

Your updated solution still causes the error icon to disappear as you are setting the error on the input layout, not the edit text. Doing it your way causes the visibility icon to show, but the error icon and tooltip goes away, which is the functionality I'm after.

I see. The commit I linked makes the error message match Material specifications so I believe your use case is different from what I was going for.
image

@LaurieScheepers
Copy link

Going back to the original bug-report: the two icons overlap, meaning there is no current way to enable both password visibility toggling and have the error icon showing properly on the edit text.

You might have solved your problem, but the bug persists.

Thanks for the help anyway :)

@leticiarossi
Copy link
Contributor

leticiarossi commented Jul 27, 2020

It seems like you're using a Widget.Design.TextInputLayout style, is that the case? That style isn't completely supported anymore - it doesn't support showing the error icon. Can you switch to using one of the Widget.MaterialComponents.TextInputLayout.* styles and check if the issue persists?
If you can't, I think the best alternative is to use a TextWatcher so that you can control when to show/hide the icons.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants