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.03k stars 1.16k forks source link

Issues with `Keyboard` and `TextField` on iOS. #3621

Closed robxyy closed 1 week ago

robxyy commented 1 year ago

Describe the bug Here are three issues about Keyboard And TextField:

Affected platforms Select one of the platforms below:

Versions

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

https://github.com/robxyy/keyboard-issues

Screenshots

https://github.com/JetBrains/compose-multiplatform/assets/9105106/1c2642be-dd92-4e9c-a3f9-8ef0c6a3427c

m-sasha commented 1 year ago

@robxyy I wasn't able to reproduce "No TextField on the screen, but the Keyboard is open." What exactly is happening at the end of the video? Or maybe there's a shorter reproduction for it?

robxyy commented 1 year ago

@robxyy I wasn't able to reproduce "No TextField on the screen, but the Keyboard is open." What exactly is happening at the end of the video? Or maybe there's a shorter reproduction for it?

Yes, at the end of the video, when I leave Screen2 , clicking the current screen or other button will automatically open the keyboard, probably related to focus.

m-sasha commented 1 year ago

Yes, at the end of the video, when I leave Screen2 , clicking the current screen or other button will automatically open the keyboard, probably related to focus.

Doesn't seem to reproduce for me.

m-sasha commented 1 year ago

By the way, to get the keyboard to show up in the simulator, I need to "disconnect" and "connect" a hardware keyboard:

image
robxyy commented 1 year ago

Yes, at the end of the video, when I leave Screen2 , clicking the current screen or other button will automatically open the keyboard, probably related to focus.

Doesn't seem to reproduce for me.

Thanks, I found a way to reproduce, when I use the Chinese input method in Screen2 and leave the input in an unfinished state, then click the Screen1 or goTo Screen3 button to automatically open the keyboard.

TheMelody commented 1 year ago

Replace: Modifier.fillMaxWidth().defaultMinSize(minHeight = 200.dp)

Modifier.fillMaxWidth().requiredHeightIn((maxHeight = 200.dp)

or Modifier.fillMaxSize()

jxdom commented 1 year ago

I also have the same problem, I am using TabRow, when Screen1 textfield uses Chinese input method, after clicking screen2, the input method will always be displayed and cannot be hidden. It should be noted that if the English input method is used in screen1, this bug will not be repeated, it seems that this bug only exists when using the Chinese input method

jQrgen commented 1 year ago

Same issue here:

https://github.com/JetBrains/compose-multiplatform/assets/3964957/1bbdd1e1-264d-478c-bd03-0218cf7c88ec

robxyy commented 12 months ago

Update: Crash when using Chinese input method on 1.5.10-beta02, caused by SkikoUIView.kt#L513

dima-avdeev-jb commented 12 months ago

Update: Crash when using Chinese input method on 1.5.10-beta02, caused by SkikoUIView.kt#L513

Thanks, added to main description as well

mazunin-v-jb commented 11 months ago

@robxyy I don't quite understand first issue here:Extra space between Keyboard and TextField Could you please provide more detailed description of reproducing this? Or just link me to messages here in case if it is already here and I missed them. By the linked video I assume that it is a part of second problem, not a separate one.

robxyy commented 11 months ago

@mazunin-v-jb Yes, it looks like part of the second problem. In this screenshot, there is a blank space between Keyboard and Column, refer: #3485. If you don't mind my asking, could you let me know in which version you plan to fix these issues?

image
mazunin-v-jb commented 11 months ago

@robxyy thank you for provided example. We're planning to take it into work in the nearest future but for now I can't say anything specific about version where it is planned to be fixed.

robxyy commented 9 months ago

Update: v1.6.0-dev1357 has fixed the problem of automatically opening the keyboard.

gandrewstone commented 6 months ago

Note for the whitespace above soft keyboard problem, the workaround mentioned in https://github.com/JetBrains/compose-multiplatform/issues/3485#issuecomment-1681791377 works for me in compose 1.6.0:

ComposeContentView().ignoresSafeArea(.keyboard,.all)
oblakr24 commented 4 months ago

Any updates here? This still does not work on 1.6.10. I tried .ignoresSafeArea(.keyboard,.all). My content is a Scaffold with

   bottomBar = {

                TextField(value = "", onValueChange = { a ->
                   // TODO
                })
        }

The footer scrolls to be on top of the keyboard, but so does the entire content, including the topBar in the scaffold (which should be pinned at the top).

bevcastillo commented 3 months ago

I'm still having keyboard issues here same with @oblakr24. Any updates?

oblakr24 commented 3 months ago

@bevcastillo in my case, .imePadding() on the footer (the part which is supposed to be pinned atop the keyboard) did the trick. My ContentView in SwiftUI has .ignoresSafeArea(.keyboard). Another thing that was needed was to make sure onFocus behavior on ComposeUIViewController is set up as

return ComposeUIViewController(configure = {
        this.onFocusBehavior = OnFocusBehavior.DoNothing // We let the scaffold's IME padding modifiers adjust the keyboard padding
    }

That said, the keyboard opening/closing is still choppy, compared to native iOS apps.

okushnikov commented 1 month ago

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