I'm trying to implement a custom VisualTransformation
for TextField
in Jetpack compose. While debugging I found that originalToTransformed
of OffsetMapping
keeps on calling. Is this an intended behavior or any fix is available for this? I have tested multiple codes even from other GitHub repos, all behave the same.
I just started implementing one of these for the first time yesterday, and I noticed the same behavior. I'm not 100% certain, but I believe it's because of the blinking cursor. Every time the cursor blinks, it looks like the originalToTransformed function is invoked.
I set a breakpoint on the first line of my implementation and then opened my form in the simulator, and this seems to confirm what I am saying. Once I get past all the initial calls for other reasons, it hits the breakpoint each time the cursor blinks.
I don't know if there is a way to prevent this behavior, but the default seems a bit strange to me that it would continue to calculate the offset each time the cursor blinks, even when the input has not changed. If you happened to have a costly offset calculation, which you probably should not, you might be able to get fancy by tracking that you already computed a transformed offset for the same field value and original offset and skip recomputing the transformed offset.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With