Status Update
Comments
si...@google.com <si...@google.com>
ng...@gmail.com <ng...@gmail.com> #2
Any news about this issue?
op...@gmail.com <op...@gmail.com> #3
na...@gmail.com <na...@gmail.com> #4
I have the same issue.
Jetpack Compose version: 1.0.2
My code:
@ExperimentalComposeUiApi
@Composable
fun Code(modifier: Modifier = Modifier, onCodeInputted: (String) -> Unit = {}) {
val passcodeLength = 6
val codeArray = remember {
Array(passcodeLength) {
mutableStateOf(TextFieldValue(text = ""))
}
}
val focusRequesters = remember {
(0 until passcodeLength).map { FocusRequester() }
}
Row(modifier = modifier) {
repeat(passcodeLength) { textFieldIndex ->
OutlinedTextField(
modifier = Modifier
.weight(1f)
.onPreviewKeyEvent {
if (it.type == KeyEventType.KeyDown && it.key == Key.Backspace &&
textFieldIndex != 0 && codeArray[textFieldIndex].value.text.isEmpty()
) {
codeArray[textFieldIndex - 1].value =
codeArray[textFieldIndex - 1].value.copy(text = "")
focusRequesters[textFieldIndex - 1].requestFocus()
}
false
}
.focusRequester(focusRequesters[textFieldIndex]),
value = codeArray[textFieldIndex].value,
textStyle = LocalTextStyle.current.copy(
textAlign = TextAlign.Center
),
singleLine = true,
keyboardOptions = KeyboardOptions.Default.copy(
keyboardType = KeyboardType.Number,
imeAction = ImeAction.Next
),
onValueChange = { newTextFieldValue ->
val newString = newTextFieldValue.text
if (newString.isDigitsOnly() && codeArray[textFieldIndex].value.text != newString) {
codeArray[textFieldIndex].value =
if (newString.length > 1) {
newTextFieldValue.copy(text = newString[0].toString())
} else newTextFieldValue
if (newString != "") {
val nextEmpty =
codeArray.indices.firstOrNull { codeArray[it].value.text == "" }
if (nextEmpty != null) {
focusRequesters[nextEmpty].requestFocus()
} else {
onCodeInputted(codeArray.joinToString(separator = "") { it.value.text })
}
}
}
}
)
if (textFieldIndex != passcodeLength - 1) {
Spacer(Modifier.width(10.dp))
}
}
}
}
[Deleted User] <[Deleted User]> #5
zo...@gmail.com <zo...@gmail.com> #6
r....@gmail.com <r....@gmail.com> #7
ch...@gmail.com <ch...@gmail.com> #8
kl...@google.com <kl...@google.com>
gb...@appolica.com <gb...@appolica.com> #9
ja...@gmail.com <ja...@gmail.com> #10
[Deleted User] <[Deleted User]> #11
al...@deliverymuch.com.br <al...@deliverymuch.com.br> #12
ch...@gmail.com <ch...@gmail.com> #13
mi...@gmail.com <mi...@gmail.com> #14
iv...@gmail.com <iv...@gmail.com> #15
Hope google will pay its attention on this bug someday :D
ha...@gmail.com <ha...@gmail.com> #16
jo...@gmail.com <jo...@gmail.com> #17
sc...@gmail.com <sc...@gmail.com> #18
mi...@gmail.com <mi...@gmail.com> #19
br...@gmail.com <br...@gmail.com> #20
Video attached. Seems like a pretty big issue, might delay are move to Compose over this.
la...@gmail.com <la...@gmail.com> #21
Perhaps a walk around ?
ch...@hotstar.com <ch...@hotstar.com> #22
ja...@gmail.com <ja...@gmail.com> #23
6o...@gmail.com <6o...@gmail.com> #24
ko...@gmail.com <ko...@gmail.com> #25
mu...@gmail.com <mu...@gmail.com> #26
kl...@google.com <kl...@google.com> #28
Probably the same bug, but I've noticed just using the backspace button in a single text field can also cause this to happen, it's like the keyboard/IME is being reloaded with every backspace!
Can you share repro code? I can definitely reproduced the issue with the code in the original issue description, but I haven't been able to reproduce with just backspace in a single field.
th...@gmail.com <th...@gmail.com> #29
Is there any workaround available for this issue?
ct...@gmail.com <ct...@gmail.com> #30
ap...@google.com <ap...@google.com> #32
Branch: androidx-main
commit 3f9688cc817a0620544193538d92d40ed730a195
Author: Zach Klippenstein <klippenstein@google.com>
Date: Sun Jan 16 18:12:45 2022
Debounce restart input commands in TextInputServiceAndroid.
In Compose, we hide the soft keyboard and close the input connection every time the text field loses focus.
Android, as far as I can tell, only does this cleanup when focus is being truly cleared and not moving to another view, which only happens after the window is detached.
This means that when focus is moved between multiple Android TextViews, each one starts a new input session without closing the old one, in a single (atomic-ish) step, and if the IME options are the same then the keyboard doesn’t change. This bug happens in Compose because we first close the connection before opening another one, and so the keyboard will reset to its default state before the IME options from the new field are applied from its new session.
The fix is to debounce restartInput operations on the IME in the same way
that we already debounce show/hide operations.
See this doc for more discussion about what caused this bug and how
it's fixed:
Fixes:
Test: Manual testing to verify the issue described in
Test: Unit tests for the new TextInputServiceAndroid debouncing:
./gradlew :compose:ui:ui:test
Test: Additional integration test that text fields are calling the right
PlatformTextInputService methods when focus changes.
Relnote: "The soft keyboard input type no longer flickers when changing
focus between text fields."
Change-Id: I1bf50cacddd8e20f9bd3d5124f277e5fef467ac0
M compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/text/CoreTextFieldInputServiceIntegrationTest.kt
M compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/text/TextFieldDelegate.kt
M compose/ui/ui/src/androidMain/kotlin/androidx/compose/ui/platform/AndroidComposeView.android.kt
M compose/foundation/foundation/src/test/kotlin/androidx/compose/foundation/text/TextFieldDelegateTest.kt
A compose/foundation/foundation/integration-tests/foundation-demos/src/main/java/androidx/compose/foundation/demos/text/TextFieldFocusKeyboardInteraction.kt
A compose/ui/ui/src/test/kotlin/androidx/compose/ui/text/input/TextInputServiceAndroidCommandDebouncingTest.kt
M compose/foundation/foundation/integration-tests/foundation-demos/src/main/java/androidx/compose/foundation/demos/text/TextDemos.kt
M compose/ui/ui/src/androidMain/kotlin/androidx/compose/ui/text/input/TextInputServiceAndroid.android.kt
M compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/platform/LocalSoftwareKeyboardControllerTest.kt
mo...@gmail.com <mo...@gmail.com> #33
kl...@google.com <kl...@google.com> #34
That fix went out in 1.2.0-alpha03.
di...@gmail.com <di...@gmail.com> #35
sh...@gmail.com <sh...@gmail.com> #36
Note: It occurs only when windowSoftInputMode is set to 'adjustResize'.
jo...@langlive.com <jo...@langlive.com> #37
si...@sentbe.com <si...@sentbe.com> #38
While the text field is focused, try opening the modal bottom sheet through some operation(e.g. pressing a button).
When the bottom sheet is opened, the keyboard closes. After closing the bottom sheet, if you press the text field again to raise the keyboard, the keyboard option changes to Default.
but, if you remove the focus of the text field and open the bottom sheet, keyboard option will not change.
I think the system is causing an unexpected (bottom sheet) behavior that kills the keyboard and overrides the ime option.
I want to keep the keyboard options regardless of focus.
sy...@gmail.com <sy...@gmail.com> #39
kl...@google.com <kl...@google.com> #40
The comments on this issue since it's been closed seem to be discussing multiple different bugs. Please file new bugs for these.
Description
Jetpack Compose release version: 1.0.0-beta06
Android Studio Build: Android Studio Arctic Fox | 2020.3.1 Canary 15 Build #AI-203.7717.56.2031.7321754, built on April 28, 2021 Runtime version: 11.0.10+0-b96-7281165 x86_64 VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o. macOS 11.2.3 GC: G1 Young Generation, G1 Old Generation Memory: 2048M Cores: 16 Registry: external.system.auto.import.disabled=true Non-Bundled Plugins: idea.plugin.protoeditor, org.jetbrains.kotlin, org.intellij.plugins.markdown
I’m facing a strange behavior with focus + keyboard type… All the
TextField
s are numeric and when I move the focus to the previousTextField
, the keyboard type changes very quickly to the alpha numeric and then changes back again to the numeric…Here’s my code:
Please see the attached GIF which demonstrate the scenario. This is happening both on emulator and real device.