-
Notifications
You must be signed in to change notification settings - Fork 41
Open
Description
Code
Layout:
<?xml version="1.0" encoding="utf-8"?>
<com.google.android.material.textfield.TextInputLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/inputLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="16dp">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/editText"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</com.google.android.material.textfield.TextInputLayout>
Activity:
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
val binding = ActivityMainBinding.inflate(layoutInflater)
setContentView(binding.root)
val kit = PhoneNumberKit.Builder(this).build()
kit.attachToInput(binding.inputLayout, "us")
kit.setupCountryPicker(this)
}
}
Reproduction steps
- Run the app.
- Click on the flag
- Choose any country
- Click on the flag again
- Choose the same country as in step 3.
Result
The text field is empty
Expected behavior
The text field contains area code of the selected country.
Possible cause:
After country is selected, the text field is cleared:
| clearInputValue() |
Then, the value of state is updated with the correct country code:
| state.value = State.Attached( |
The problem is the following: the new value of
state is exactly the same as the previous one (as we are reselecting the same country). MutableStateFlow does not emit a new value to its collectors if we set the same value.That's why the following line is not called:
| inputValue = state.country.code.toString() |
And the text field stays empty.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels