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

Fabio

03/18/2022, 1:39 PM
I started adopting Compose 1.1.1 in an existing Android app but I'm facing very weird behavior when trying to limit input in a
TextField
to decimal numbers. I just posted a question on StackOverflow with the full details, but I could also post them here if you prefer. The TL;DR is that even if I do not update my state in response to the
onValueChange
callback (or if I just set the previous value and ignore the new one), the text I get in the next
onValueChange
still includes the changes I rejected.
r

Robert Menke

03/18/2022, 2:55 PM
Try using a regular string and not using the inner data class
f

Fabio

03/18/2022, 2:57 PM
I tried something like that, having either a
String
or a
TextFieldValue
as local remembered state in the composable and getting rid of the view model altogether, and encountered the same or similar results
b

Bradleycorn

03/18/2022, 3:09 PM
I have a couple defects around this filed on the issue tracker. I think one has been fixed, and the other is still outstanding. Let me get a link …
hmm … supposedly this one is fixed too https://issuetracker.google.com/issues/200577798
f

Fabio

03/18/2022, 3:11 PM
awesome, I did a quick search in the issue tracker before posting here but did not find your issues. Thanks for the links!
b

Bradleycorn

03/18/2022, 3:12 PM
The 2nd one had it’s fix committed on Jan 22 … So maybe it hasn’t made it into a release yet?
the first one was fixed on Feb 9, so maybe it also has not made it into a release yet
f

Fabio

03/18/2022, 3:18 PM
were you able to implement any workarounds? I've tried a few, but nothing that worked so far, so I'm basically unable to have a filtered text field in the app for now
r

Robert Menke

03/18/2022, 3:23 PM
I can send you an example of what I have a bit later - I have several text fields that do filtering
f

Fabio

03/18/2022, 5:52 PM
FWIW my issue is fixed in
1.2.0-alpha05
2 Views