material-components / material-components/material-components-android

[TextField] disabling hint prevents custom `defaultHintTextColor`

Open
#3,986 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug Widget: TextField
Dominant language
Java
Stars
17.4k
Forks
3.2k
PR merge metrics
No merged PRs in 30d

Description

Description:
I want to have textfield with disabled floating hint but with custom hint color for when the textfield is empty.

Let say i have a textfield with floating hint enabled.
I use setDefaultHintTextColor to change the hint color. It works and changes the color for expanded and collapsed.

Now i call setHintEnabled(false).
The floating hint gets disabled (expanded) but i still see the hint collapsed when there is no text (which is what i want).
However i loose the custom colors i set with setDefaultHintTextColor for when there is no text

Expected behavior: Screenshots and/or description of expected behavior
The setDefaultHintTextColor to be preserved while using setHintEnabled(false)

Source code: The code snippet which is causing this issue

Minimal sample app repro: Please consider attaching a minimal sample app that reproduces the issue. This will help narrow down the conditions required for reproducing the issue, and it will speed up the bug fix process. You may attach a zip file of the sample app or link to a GitHub repo that contains the sample app.

Android API version: 13, 11, 10

Material Library version: 1.11.0
Device: Emulator/real devices

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with a minimal Android reproduction on Material Library 1.11.0, calling setDefaultHintTextColor and then setHintEnabled(false) on a textfield. Trace the TextField behavior around these two entry points across the listed Android API versions, and consider the issue done when the custom color remains visible for the collapsed hint while the floating hint stays disabled.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, java
Domain
mobile
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.