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

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

Open robxyy opened this issue 2 years ago • 19 comments

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

  • https://github.com/JetBrains/compose-multiplatform/issues/4016
  • [x] When a TextField is included in a scrollable Column, if TextField is long enough, TopAppBar will exceed the edge of the screen.
  • [x] No TextField on the screen, but the Keyboard is 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 avatar Sep 05 '23 04:09 robxyy

@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?

m-sasha avatar Sep 06 '23 12:09 m-sasha

@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.

robxyy avatar Sep 06 '23 13:09 robxyy

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 avatar Sep 06 '23 13:09 m-sasha

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

image

m-sasha avatar Sep 06 '23 13:09 m-sasha

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.

robxyy avatar Sep 06 '23 13:09 robxyy

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

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

or Modifier.fillMaxSize()

TheMelody avatar Sep 11 '23 06:09 TheMelody

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

jxdom avatar Sep 21 '23 03:09 jxdom

Same issue here:

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

jQrgen avatar Sep 25 '23 17:09 jQrgen

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

robxyy avatar Oct 09 '23 01:10 robxyy

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

Thanks, added to main description as well

dima-avdeev-jb avatar Oct 09 '23 06:10 dima-avdeev-jb

@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 avatar Oct 25 '23 19:10 mazunin-v-jb

@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

robxyy avatar Oct 26 '23 03:10 robxyy

@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.

mazunin-v-jb avatar Oct 26 '23 09:10 mazunin-v-jb

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

robxyy avatar Jan 06 '24 14:01 robxyy

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)

gandrewstone avatar Mar 15 '24 14:03 gandrewstone

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).

oblakr24 avatar May 30 '24 16:05 oblakr24

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

bevcastillo avatar Jul 01 '24 10:07 bevcastillo

@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.

oblakr24 avatar Jul 01 '24 11:07 oblakr24

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

okushnikov avatar Aug 26 '24 13:08 okushnikov