material-components-android icon indicating copy to clipboard operation
material-components-android copied to clipboard

[TextInputEditText] Hint color and Cursor color do not update when the parent TextInputLayout goes to Error state

Open zeamend opened this issue 3 years ago • 2 comments
trafficstars

Description: As shown in the image below, the hint color and cursor color do not update to the error color when the parent TextInputLayout is in the error state. Instead, the cursor color is still set to colorPrimary (the blue), and the hint color is still set to colorOnSurface (the light gray).

Cursor Color Wrong

Expected behavior: When in an error state, the hint color and cursor color should update to be the same as the boxBorderColor as shown in the interactive demo from the Material Text Field docs.

Source code: XML:

<com.google.android.material.textfield.TextInputLayout
                       android:id="@+id/email_input_layout"
                       style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox.Dense"
                       android:layout_width="match_parent"
                       android:layout_height="wrap_content"
                       android:hint="@string/email"
                       app:layout_constraintBottom_toTopOf="@id/unimportant_layout"
                       app:layout_constraintTop_toBottomOf="@id/other_unimportant_layout">

                       <com.google.android.material.textfield.TextInputEditText
                           android:id="@+id/email_input_text"
                           android:layout_width="match_parent"
                           android:layout_height="wrap_content"
                           android:inputType="textEmailAddress" />

And then at some point in the Fragment:

binding.emailInputLayout.error = "Empty field"

Android API version: 31

Material Library version: 1.6.0

Device: Google Pixel 6

zeamend avatar May 26 '22 01:05 zeamend

From the doc I think the hint color is correct (it shouldn't change itself to colorError.)

But the cursor color should be changed.

drchen avatar Jun 09 '22 19:06 drchen

Hi, is this issue still open? I would like to work on it if possible.

RivanParmar avatar Jul 04 '22 09:07 RivanParmar