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] voice dictation text does not register with text fields using TextFieldValue #5044

Open
garrison-henkle opened this issue Jun 28, 2024 · 1 comment
Assignees
Labels
bug Something isn't working ios text

Comments

@garrison-henkle
Copy link

Describe the bug
When using the iOS stock keyboard's voice dictation in a BasicTextField using TextFieldValue, the dictated text is cleared when voice dictation is disabled.

Affected platforms

  • iOS

Versions

  • Libraries:
    • Compose Multiplatform version: 1.6.11
  • Kotlin version: 2.0.0
  • OS version(s) (required for Desktop and iOS issues): iOS 17.5.1
  • OS architecture (x86 or arm64): N/A
  • Device (model or simulator for iOS issues): iPhone SE 2020, but reported on newer models as well
  • JDK (for desktop issues): N/A

To Reproduce
Steps to reproduce the behavior:

  1. Create a BasicTextField using TextFieldValue e.g.
var textState by remember { mutableStateOf(TextFieldValue()) }
BasicTextField(
    value = textState,
    onValueChange = { textState = it },
)
  1. Click on the voice dictation button on the stock iOS keyboard
  2. Dictate
  3. Tap on the screen to end the dictation
  4. The text will disappear as soon as dictation ends

Repo that reproduces the issue on my device:
https://github.com/garrison-henkle/composeMultiplatformVoiceDictationBug

Expected behavior
The text does not disappear when dictation ends

Screenshots
https://github.com/JetBrains/compose-multiplatform/assets/70973354/d4997920-0a77-479e-a5a9-26b7be7259a1

Additional context

@garrison-henkle garrison-henkle added bug Something isn't working submitted labels Jun 28, 2024
@garrison-henkle
Copy link
Author

garrison-henkle commented Jun 30, 2024

I played around with the debugger / print statements for a bit this afternoon. To reproduce in the compose-multiplatform-core repo, I added the following to androidx.compose.mpp.demo.textfield.android.TextFieldValueDemo:

item {
    TagLine("TextFieldValue overload")
    var state by remember { mutableStateOf(TextFieldValue()) }
    BasicTextField(
        value = state,
        onValueChange = { state = it },
        textStyle = TextStyle(fontSize = fontSize8),
        modifier = demoTextFieldModifiers
    )
}

So far, the issue seems be somewhere afteronValueChangeOriginal is called in CoreTextField's onValueChange here. It is called with the correct TextFieldValue containing the dictated text, but the callback in the BasicTextField that I'm using receives what looks like a brand new empty TextFieldValue instance instead.

There is a currentRecomposeScope.invalidate() that is called immediately after the onValueChangeOriginal call, so I wonder if that is breaking something.

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 text
Projects
None yet
Development

No branches or pull requests

3 participants