JetBrains / compose-multiplatform

Compose Multiplatform, a modern UI framework for Kotlin that makes building performant and beautiful user interfaces easy and enjoyable.
https://jetbrains.com/lp/compose-multiplatform
Apache License 2.0
16.2k stars 1.17k forks source link

OutlinedTextField in iOS app exhibits strange behavior #3952

Closed jamesbmorris4444 closed 1 month ago

jamesbmorris4444 commented 11 months ago

Describe the bug OutlinedTextField in iOS app exhibits strange behavior. The code is here:

val text by viewModel.refreshEditTextState.collectAsState()
            Spacer(modifier = Modifier.height(36.dp))
            Row {
                OutlinedTextField(
                    modifier = Modifier
                        .weight(0.7f)
                        .height(60.dp)
                        .testTag("OutlinedTextField"),
                    value = text,
                    onValueChange = {
                        viewModel.refreshEditTextState(it)
                    },
                    shape = RoundedCornerShape(10.dp),
                    label = { Text(Strings.get("initial_letters_of_last_name_text")) },
                    singleLine = true,
                    keyboardOptions = KeyboardOptions(imeAction = ImeAction.Done),
                    keyboardActions = KeyboardActions(
                        onDone = {
                            keyboardController?.hide()
                            handleSearchClick(text)
                        })
                )
            }

A video is attached. This issue occurs only on iOS. The same code on Android behaves normally.

Affected platforms Select one of the platforms below:

Versions

To Reproduce Steps and/or the code snippet to reproduce the behavior:

  1. Click in OutlinedTextField and then type letters.
  2. Observe the problem

Expected behavior Normal behavior, which I get with the same code on Android.

Screenshots Video is here at this link

https://drive.google.com/file/d/1HFfA3IJ3IUiqDapBxpbAw5HYuLRA80hR/view?usp=drive_link

Additional context Add any other context about the problem here.

elijah-semyonov commented 11 months ago

It is a known problem and will be fixed eventually. For a temporary fix, avoid using StateFlow inside text input processing scope.

okushnikov commented 2 months ago

Please check the following ticket on YouTrack for follow-ups to this issue. GitHub issues will be closed in the coming weeks.