https://kotlinlang.org logo
#compose
Title
# compose
a

Ayfri

02/05/2022, 12:15 AM
Hi, I have multiple textfields that can be errored, and I have a button to validate everything, and I want to only enable the validate button when no fields are errored, so I created a first-class array of strings, and when an field is errored, the name of the field is added to the array, and my button has the property
enabled = array.isEmpty()
but the problem is that the button enabled state is only updated after the array has changed Like if I have a field errored, the array has correctly a new value inside, but the button is only updated when the list is updated after this (like adding/removing an element), not directly when a new element is added to array
a

Albert Chang

02/05/2022, 6:05 AM
Is your array a mutable state?
a

Ayfri

02/05/2022, 11:43 AM
Yes, it's a
mutableStateListOf<String>()
a

Albert Chang

02/05/2022, 12:50 PM
Then file an issue with a repro.
a

Ayfri

02/05/2022, 12:55 PM
Oh it's really a bug of Compose ?
a

Albert Chang

02/05/2022, 12:57 PM
You are not posting any code but from what you described, yes.
a

Ayfri

02/05/2022, 1:48 PM
Ah, while re-reading my code, I've seen that I misplaced the line where I add the error, and now it is fixed, thanks for support nonetheless ^^