compose-multiplatform
compose-multiplatform copied to clipboard
Issues with `Keyboard` and `TextField` on iOS.
Describe the bug
Here are three issues about Keyboard And TextField:
- https://github.com/JetBrains/compose-multiplatform/issues/4016
- [x] When a
TextFieldis included in a scrollableColumn, ifTextFieldis long enough,TopAppBarwill exceed the edge of the screen. - [x] No
TextFieldon the screen, but theKeyboardis open. - [x] Crash when using Chinese input method on 1.5.10-beta02, caused by SkikoUIView.kt#L513
Affected platforms Select one of the platforms below:
- iOS
Versions
- Kotlin version*: 1.9.0
- Compose Multiplatform version*: 1.5.0
- OS version(s)* (required for Desktop and iOS issues): all
- OS architecture (x86 or arm64): all
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
@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 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.
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.
By the way, to get the keyboard to show up in the simulator, I need to "disconnect" and "connect" a hardware keyboard:
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.
Replace: Modifier.fillMaxWidth().defaultMinSize(minHeight = 200.dp)
Modifier.fillMaxWidth().requiredHeightIn((maxHeight = 200.dp)
or
Modifier.fillMaxSize()
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
Same issue here:
https://github.com/JetBrains/compose-multiplatform/assets/3964957/1bbdd1e1-264d-478c-bd03-0218cf7c88ec
Update: Crash when using Chinese input method on 1.5.10-beta02, caused by SkikoUIView.kt#L513
Update: Crash when using
Chinese input methodon1.5.10-beta02, caused by SkikoUIView.kt#L513
Thanks, added to main description as well
@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.
@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?
@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.
Update: v1.6.0-dev1357 has fixed the problem of automatically opening the keyboard.
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)
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).
I'm still having keyboard issues here same with @oblakr24. Any updates?
@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.
Please check the following ticket on YouTrack for follow-ups to this issue. GitHub issues will be closed in the coming weeks.