From f378f93148e70d95b142d3cb27fe796ba81e7bac Mon Sep 17 00:00:00 2001 From: pubiqq Date: Mon, 16 Mar 2026 14:14:33 +0300 Subject: [PATCH] [TextField] Match cursor error color to text field state --- .../google/android/material/textfield/TextInputLayout.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/java/com/google/android/material/textfield/TextInputLayout.java b/lib/java/com/google/android/material/textfield/TextInputLayout.java index 2f664d8fb7f..c87ac1534f1 100644 --- a/lib/java/com/google/android/material/textfield/TextInputLayout.java +++ b/lib/java/com/google/android/material/textfield/TextInputLayout.java @@ -4577,7 +4577,10 @@ private void updateCursorColor() { Drawable cursorDrawable = DrawableCompat.wrap(editText.getTextCursorDrawable()).mutate(); if (isOnError() && cursorErrorColor != null) { - color = cursorErrorColor; + int defaultCursorErrorColor = cursorErrorColor.getDefaultColor(); + int targetCursorErrorColor = cursorErrorColor.getColorForState( + editText.getDrawableState(), defaultCursorErrorColor); + color = ColorStateList.valueOf(targetCursorErrorColor); } cursorDrawable.setTintList(color); }