I am using a Jetpack Compose `OutlinedTextField` a...
# compose
s
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 it is in thread,
Copy code
@Composable
fun ScannerScreen() {
    var barCode by remember { mutableStateOf("") }
    var scannedBarCode by remember { mutableStateOf("") }

    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
            )
    }
}
c
Have you tried removing the default.copy on it and just use KeyboardOptions()
s
Yes, but same result
c
Then i think the problem is the LaunchedEffect try removing it