I am using a Jetpack Compose OutlinedTextField and have set its KeyboardOptions to showKeyboardOnFocus = false. According to the documentation, this should prevent the soft keyboard from appearing automatically when the TextField gains focus. However, despite this setting, the soft keyboard is still showing up when the field receives focus. Has anyone else encountered this specific issue where the showKeyboardOnFocus = false flag is not working as expected,? ComposeBom version used is “2025.04.00”. Minimal code example to reproduce
val focusRequester = remember { FocusRequester() }
val focusManager = LocalFocusManager.current
LaunchedEffect(Unit) {
focusRequester.requestFocus()
}
Column(
modifier = Modifier
.fillMaxSize()
.padding(16.dp)
) {
OutlinedTextField(
value = barCode,
onValueChange = { barCode = it },
label = { Text("Barcode") },
placeholder = { Text("Enter Barcode") },
singleLine = true,
keyboardOptions = KeyboardOptions.Default.copy(
keyboardType = KeyboardType.Number,
imeAction = ImeAction.Done,
showKeyboardOnFocus = false
),
keyboardActions = KeyboardActions(
onDone = {
scannedBarCode = barCode
focusManager.clearFocus()
}
),
modifier = Modifier
.fillMaxWidth()
.focusRequester(focusRequester)
)
if (scannedBarCode.isNotBlank())
Text(
text = "Entered(Scanned) Barcode: $scannedBarCode",
style = MaterialTheme.typography.bodyMedium
)
}
Keyboard still showing when field get focus.