Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

iOS Keyboard Broken with readOnly will show/hide in loop #5088

Closed
chrisjenx opened this issue Jul 9, 2024 · 13 comments
Closed

iOS Keyboard Broken with readOnly will show/hide in loop #5088

chrisjenx opened this issue Jul 9, 2024 · 13 comments
Assignees
Labels
bug Something isn't working ios

Comments

@chrisjenx
Copy link

chrisjenx commented Jul 9, 2024

Focus is not respected for readOnly textfields on iOS causing the second tap to cause an infinate loop of showing/hiding the keyboard, see video.
On older versions, readonly won't show the keyboard. But it also will show then hide if trying to create a filter style drop down.

Looking at the errors looks like the textview get incorrectly recomposed or focus removed so iOS removes the keyboard:

-[RTIInputSystemClient remoteTextInputSessionWithID:performInputOperation:]  perform input operation requires a valid sessionID. inputModality = Keyboard, inputOperation = <null selector>, customInfoType = UIEmojiSearchOperations

Affected platforms

  • iOS

Versions

  • Libraries:

    • Compose Multiplatform version: 1.6.10/1.6.11/1.7.x
  • Kotlin version: 2.0.0,1.9.23

To Reproduce

ExposedDropdownMenuBox(
            expanded = expanded,
            onExpandedChange = { expanded = it },
        ) {
            TextField(
                modifier = Modifier.fillMaxWidth(1f).menuAnchor(
                    type = MenuAnchorType.PrimaryNotEditable,
                ),
                readOnly = true,
            )
 /// etc
}

Watch the video closely, you tap once to show the drop down, then tap to close it, the next time you tap to reopen the same drop down it start going crazy.

Expected behavior
Keyboard should not show, second click should hide the popup (as should scrolling etc)

RPReplay_Final1720539286.mov

Updated, tried 1.6.1x+ and broken on there too. Downgrading to 1.6.1 again...

@chrisjenx chrisjenx added bug Something isn't working submitted labels Jul 9, 2024
@MatkovIvan MatkovIvan self-assigned this Jul 9, 2024
@MatkovIvan
Copy link
Member

Hm.. it should be there 🤔

I'll take a look, thanks for the report

@MatkovIvan MatkovIvan added the p:high High priority label Jul 9, 2024
@chrisjenx
Copy link
Author

This also is slightly broken on 1.6.10/11, but no where near as janky as this. On 1.6.1x it will show the keyboard once but then not again, seems like on iOS it doens't know who should hold focus causing this back and forth.

@chrisjenx
Copy link
Author

Broken on 1.6.1x so downgrading again...

@chrisjenx
Copy link
Author

Hm.. it should be there 🤔

I'll take a look, thanks for the report

Note, you won't see this on an emulator, you need a physical device. As the emulators are faster/don't show keyboard on focus by default

@chrisjenx
Copy link
Author

Well the more I test the more I realize dropdown with keyboard is just plain broken on iOS, basically the popup always steals the focus so the keyboard auto closes.
All versions since 1.6.0 (as far back as I tested) will eventually throw:

-[RTIInputSystemClient remoteTextInputSessionWithID:performInputOperation:]  perform input operation requires a valid sessionID. inputModality = Keyboard, inputOperation = <null selector>, customInfoType = UIEmojiSearchOperations

Remove the menuAnchor and starts showing keyboard again.

Seems like compose compiler will start writing the text view in a way where it aways will recompose the textfield causing the keyboard not to be able to focus.

This happens on 1.6.x on KT 1.9.23 forward

@chrisjenx
Copy link
Author

Created a test project for you, this is actually broken on the emulator too. What is interesting is I'm pretty sure it works first time from a clean, then you start changing stuff and then it breaks. It could be completely unrelated to menuAnchor an a iOS compile compiler issue where it's incorrectly invalidating the text field. (Cleaning all caches doesn't fix it, so not sure that theory has any validity)

TestProj.zip

@chrisjenx chrisjenx changed the title iOS Keyboard Broken with MenuAnchor and readonly (1.7.0 alpha) iOS Keyboard Broken with MenuAnchor - Won't show correctly Jul 9, 2024
@chrisjenx
Copy link
Author

Another random note that leads me to belive focus/recompose issue, if you comment out the ExposedDropdownMenu block, the Field will act correctly. It's like either the showing of the Menu popup or rendering causes a rerender of the whole DrowdownBox

@MatkovIvan MatkovIvan added the ios label Jul 10, 2024
@MatkovIvan
Copy link
Member

For 1.6.x with an editable text field inside dropdown it was tracked in #4782 and already fixed. See my comment #4782 (comment) with explanation what was that.

For 1.7.0-alpha01 - I've checked in our samples and in your project and wasn't able to reproduce it. It works as expected in both editable and noneditable variants.

Since the shared project contains an issue with the EDITABLE field from 1.6 that was already resolved and the initial message was about NON editable fields from 1.7, I kindly ask you to provide a project with reproduction for future investigation - the code snippet from the first message works fine.


@ASalavei could you please check if it's related to your change about an edit menu?

@MatkovIvan MatkovIvan added wait for reply Further information is requested and removed p:high High priority labels Jul 10, 2024
@chrisjenx
Copy link
Author

chrisjenx commented Jul 10, 2024

Updated to 1.7.x with the readOnly issue.

Tap Read only field for focus, then tap again, they keyboard starts going crazy

TestProj.zip

RPReplay_Final1720625412.MP4

@chrisjenx chrisjenx changed the title iOS Keyboard Broken with MenuAnchor - Won't show correctly iOS Keyboard Broken with readOnly will show/hide in loop Jul 10, 2024
@ASalavei
Copy link
Collaborator

@MatkovIvan , it looks like this line does the party: https://github.com/JetBrains/compose-multiplatform-core/blob/0ff7bcc245689fc6e3a7c5b2bf2cc46bca684280/compose/ui/ui/src/uikitMain/kotlin/androidx/compose/ui/platform/UIKitTextInputService.uikit.kt#L305
It definitely should be removed.

However, I can see the difference in keyboard appearing behavior. This sample behaves differently on iOS and Android. It looks like our FocusStackImpl does something wrong.

@MatkovIvan
Copy link
Member

Thanks for investigation. This is from JetBrains/compose-multiplatform-core#1269. Then, reassigning to @mazunin-v-jb

@MatkovIvan MatkovIvan removed wait for reply Further information is requested material3 labels Jul 10, 2024
@okushnikov
Copy link

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

mazunin-v-jb added a commit to JetBrains/compose-multiplatform-core that referenced this issue Jul 22, 2024
Fixed the keyboard appearing in SelectionContainer in iOS

<!-- Optional -->
Fixes: JetBrains/compose-multiplatform#4986

https://youtrack.jetbrains.com/issue/CMP-1554/iOS-Selection-Container-shows-keyboard-while-selecting-text
JetBrains/compose-multiplatform#5088

## Testing
Manual. Open Test App, go Components -> Selection, double tap any
selectable text, on-screen keyboard shouldn't appear.

## Release Notes
<!--
Optional, if omitted - won't be included in the changelog

Sections:
- Highlights
- Known issues
- Breaking changes
- Features
- Fixes

Subsections:
- Multiple Platforms
- iOS
- Desktop
- Web
- Resources
- Gradle Plugin
-->
### Fixes - iOS
- Fixed the keyboard appearing when selecting from SelectionContainer


## Google CLA
You need to sign the Google Contributor’s License Agreement at
https://cla.developers.google.com/.
This is needed since we synchronise most of the code with Google’s AOSP
repository. Signing this agreement allows us to synchronise code from
your Pull Requests as well.
@chrisjenx
Copy link
Author

chrisjenx commented Aug 11, 2024

OK looks like this was fixed by JetBrains/compose-multiplatform-core#1448 in 1.7.0-alpha02

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working ios
Projects
None yet
Development

No branches or pull requests

5 participants