Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Keyboard not showing on TextField focused in ModalBottomSheet compose

I have the following issue in compose.

I have a ModalBottomSheet which has a TextField. The keyboard does not show up when I click inside the text field. On an emulator I can type in some input with my computer keyboard shows up. On a real device though I don't have that possibility with makes the ModalBottomSheet useless.

I read this article about the same issue and there identifying the version compose-ui 1.4.0 as source of the problem. So I went to this page where they state that the issue has been fixed with version. After updating my gradle as follows the keyboard still does not show up.

implementation "androidx.compose.material3:material3:1.1.0-rc01"
implementation "androidx.compose.material3:material3-window-size- 
 class:1.1.0-rc01"
implementation 'androidx.compose.ui:ui:1.4.2'
like image 898
DeKekem Avatar asked Dec 09 '25 08:12

DeKekem


1 Answers

In case someone comes across here with a similar issue, ensure you have the isFocusable set to true (see below):

    ModalBottomSheet(
        onDismissRequest = onDismissRequest,
        dragHandle = null,
        containerColor = Color.Transparent,
        scrimColor = Color.Transparent,
        modifier = Modifier
            .fillMaxSize()
            .statusBarsPadding()
            .navigationBarsPadding(),
        sheetState = sheetState,
        shape = RectangleShape,
        properties = ModalBottomSheetProperties(
            securePolicy = SecureFlagPolicy.SecureOff,
            isFocusable = true, // IMPORTANT!!! This must be true so TextField can show keyboard
            shouldDismissOnBackPress = false
        )
    ) {
        CheckoutSheetScaffold(checkout = checkout, onDismissRequest = onDismissRequest)
    }
like image 50
user23215954 Avatar answered Dec 13 '25 17:12

user23215954



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!