Is it expected for a `VisualTransformation` to aff...
# compose
v
Is it expected for a
VisualTransformation
to affect the new value that was returned from
onValueChange
? I created a VisualTransformation and added it on a TextField but it seems that when i modify (add or delete) a character on a specific position it may affect character on another position.
z
Not sure I understand your question – if you add/remove chars, it would affect the position of all chars after it.
v
I created a VisualTransformation and i have the following effect: The expected format is
XX XXXX XXX
(To be precise this format changes dynamically based on country selection but for now i am testing this format). I have typed
210
and the cursor is on last position. I type the next character. Let’s say it is
9
. The expected behavior is for
onValueChange
to return this value
2109
but it returns
2190
. If I remove the VisualTransformation it works as expected, so it seems that somehow it creates the problem
z
VisualTransformations are famously tricky to write correctly, and in some cases impossible. If possible, use
InputTransformation
and
OutputTransformation
in the new
BasicTextField
instead.
1
v
The problem is that I need to use
OutlinedTextField
and i do not see any way to delegate these values to
BasicTextField
. Does it have to do with my current compose version?
z
It was added to material3 in 1.4, which just entered beta.
👍 1