Wear OS Loading Wrong Keyboard on Physical Device

32 views Asked by At

I have an OutlinedTextField that should only accept CAPITAL characters. I have defined the composable like this:

val keyboardController = LocalSoftwareKeyboardController.current
var textFieldValue by remember { mutableStateOf(TextFieldValue("")) }
val focusRequester = remember {
    textFieldValue = textFieldValue.copy(selection = TextRange(textFieldValue.text.length))
    FocusRequester()
}
OutlinedTextField(
    label = {
        Text(label)
    },
    value = textFieldValue,
    onValueChange = {
        textFieldValue = it
        // handle value change...
    },
    keyboardOptions = KeyboardOptions.Default.copy(
        imeAction = ImeAction.Done,
        capitalization = KeyboardCapitalization.Characters,
        autoCorrect = false
    ),
    keyboardActions = KeyboardActions(onDone = {
        keyboardController?.hide()
        // handle done
    }),
    modifier = Modifier
        .fillMaxWidth()
        .padding(bottom = 16.dp)
        .focusRequester(focusRequester)
)

This works like a charm on the emulator. However, on my Galaxy Watch 6 Classic, the keyboard loads in lowercase mode the first time, and text field does not accept any text. If I dismiss the keyboard, and trigger it again, everything works perfectly. Am I doing something wrong here? I am using package androidx.compose.material3.OutlinedTextField

0

There are 0 answers