Hi, Just wondering if anyone has opinion on this. ...
# compose-ios
a
Hi, Just wondering if anyone has opinion on this. I have the following code:
Copy code
@Composable
fun SomeTextField(value: String, onChange: (String) -> Unit, ...) {
    ...
    TextField(
        value = value,
        onValueChange = onChange,
        ...,
         keyboardOptions = KeyboardOptions(
            keyboardType = KeyboardType.NumberPassword,
            imeAction = if (someState) ImeAction.Go else ImeAction.Done,
        ),
    )
    ...
}
this line:
Copy code
imeAction = if (someState) ImeAction.Go else ImeAction.Done,
causes the ios keyboard to hide and immediately show back up. I was wonder if doing so in compose is not advisable?
a
Immediate thought - what exactly is your
someState
? I’m still fairly new to CMP but if that was some kind of binding, I could see it causing grief with state changes. I really have no feel yet for which bits of CMP cause there to be active things that rebuild visual stuff. I would do a quick test with a local
val
set to true and then to false and see if it’s the expression or the expression result changing that causes keyboard flickers
a
I’ve already tested it and it is the exact cause of the keyboard flicker. for this specific scenario for
someState
, it could be a verification of the input (
isValidEmail
or
isInputComplete
) where if the input does not fit the validation, the
ImeAction
should show Done, but when it passes the validation it should show Go.
What I don’t know at the moment is whether such behavior is intended or whether this is a valid bug to report.
a
The nuance I was thinking was, if you’re able to copy a more dynamic bound result to a local var, it may help
But my head is in SwiftUI for a couple of days so that’s maybe affecting my thinking
a
At the moment,
someState
is already local to the composable if thats what you meant.
a
Uggh, yeah sorry, ignore me, pretty sure my idioms are coming more from SwiftUI states than Compose. I’m doing something very similar in a screen I’m working on at present to choose between a numeric pad and one with decimal.
K 1
a
No worries thanks for the input.