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

[TextInputLayout] OnFocusChangeListener is only notified on first gained focus

Open
#1,015 18 comments 2 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:
Settings a OnFocusChangeListener on the TextInputEditText inside the TextInputLayout notifies the listener only the very first time the focus is gained.

Expected behavior:
The listener should always fire when focus is gained and lost.

Source code:

textInputEditText.setOnFocusChangeListener { _, hasFocus -> 
  println("only fires on first focus gained")
}

Android API version: 29

Material Library version: 1.2.0-alpha04

Device: Emulator

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 by reproducing the focus behavior with TextInputLayout and its TextInputEditText using the Kotlin listener example in the issue. Trace the focus-change handling in the Material Components Android implementation and check existing tests for TextInputLayout or TextInputEditText. Done means the listener fires on every focus gain and loss, including repeated focus cycles.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.