compose-samples icon indicating copy to clipboard operation
compose-samples copied to clipboard

[JetSurvey] Incorrect value in TextField

Open DesarrolloAntonio opened this issue 4 years ago • 6 comments

Hello, I found bug when put an email in TextField, It seems onValueChanged returns incorrect value.

Testing in JetSurvey module:

https://user-images.githubusercontent.com/7002198/137103567-839b8ca5-56e1-4308-bfa8-4bf4f0905cb7.mp4

Test in Samsung SM-T365 with Android 5.1.1 and Samsung Galaxy A6 with Android 8 fails. Test in Android 9 and newer devices works fine.

Thanks

DesarrolloAntonio avatar Oct 13 '21 09:10 DesarrolloAntonio

I wasn't able to reproduce this on an emulator running Android 5. I suspect it is something related to the way Samsung's keyboard works after handling special characters, but trying on a Galaxy Fold 3 works fine too. It's possible that it's limited to older Samsung devices and/or that an update to Compose's input management since this was filed fixed this issue.

@DesarrolloAntonio Are you able to confirm if this is still a problem for you?

IanGClifton avatar Apr 30 '22 01:04 IanGClifton

Yes, the problem continues

DesarrolloAntonio avatar Jun 15 '22 06:06 DesarrolloAntonio

@DesarrolloAntonio can you see if the following code has the same problem in a fresh compose project? I don't see anything obvious that Jetsurvey is doing that would cause this behavior, but this should help tell us if this is a problem with the sample or with Compose.

@Composable
fun Email(
    imeAction: ImeAction = ImeAction.Done,
    onImeAction: () -> Unit = {}
) {
    var text by remember { mutableStateOf("") }

    OutlinedTextField(
        modifier = Modifier.padding(16.dp),
        value = text,
        onValueChange = { text = it },
        label = { Text("Email") },
        maxLines = 1,
        keyboardOptions = KeyboardOptions.Default.copy(imeAction = imeAction),
        keyboardActions = KeyboardActions(
            onDone = {
                onImeAction()
            }
        )
    )
}

IanGClifton avatar Jun 17 '22 17:06 IanGClifton

I've created a blank project, and the problem continues. This is the result when enter "[email protected]". Screenshot_20220707_142435

DesarrolloAntonio avatar Jul 07 '22 12:07 DesarrolloAntonio

Thank you, @DesarrolloAntonio. It looks like there are a few different issues in Compose with keyboards that do predictive text. I believe this issue is the same as https://issuetracker.google.com/208855078.

IanGClifton avatar Jul 19 '22 22:07 IanGClifton

It looks like the fix in Compose Foundation went into version 1.3.0-alpha03, so this should be fixed in the compose-latest branch. We'll wait to update main until 1.3.0 stable is released.

IanGClifton avatar Sep 02 '22 17:09 IanGClifton

This should be fixed in the main branch as well now. We've updated the samples to using the Compose BOM for Oct '22, which includes the fix in Compose Foundation.

IanGClifton avatar Oct 26 '22 20:10 IanGClifton