sheets icon indicating copy to clipboard operation
sheets copied to clipboard

Bottom sheet does not update state when keyboard is closed.

Open rezafaraji93 opened this issue 2 years ago • 6 comments

Sometimes when the keyboard gets closed, the sheet remains on top of the screen like the image below: 2

rezafaraji93 avatar Jun 12 '23 18:06 rezafaraji93

Hi, Are you using the latest library version? Can you provide a code snippet to reproduce this bug?

dokar3 avatar Jun 13 '23 01:06 dokar3

This is my bottom sheet composable:

`@Composable fun Bit24ProBottomSheet( modifier: Modifier = Modifier, bottomSheetState: BottomSheetState = rememberBottomSheetState(), onDismiss: () -> Unit = {}, skipPeeked: Boolean = true, dimColor: Color = Color.Black, peekHeight: PeekHeight = PeekHeight.px(0), isFullScreen: Boolean = false, content: @Composable () -> Unit ) {

val configuration = LocalConfiguration.current

LaunchedEffect(key1 = bottomSheetState.value) {
    if (!bottomSheetState.visible) onDismiss()
}

BottomSheet(
    modifier = modifier
        .imePadding()
        .then(if (isFullScreen) Modifier else Modifier.heightIn(max = configuration.screenHeightDp.dp - dimens.standard80)),
    shape = RoundedCornerShape(topStart = dimens.standard16, topEnd = dimens.standard16),
    dragHandle = {},
    backgroundColor = newColors.bgBackground,
    state = bottomSheetState,
    skipPeeked = skipPeeked,
    dimColor = dimColor,
    peekHeight = peekHeight,
    behaviors = DialogSheetBehaviors(
        dialogWindowSoftInputMode = WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE
    ),
    content = content
)

}`

It happens sometimes and not always, suppose that on the image I sent, there is a search textfield on top and after the user typed and the keyboard is dismissed, the bottom sheet stays on top.

rezafaraji93 avatar Jun 13 '23 05:06 rezafaraji93

Thanks for the information, will check it later when I'm free.

dokar3 avatar Jun 13 '23 06:06 dokar3

After trying hundreds of times and still not being able to reproduce this bug on both an Android 12 phone and an Android 11 emulator, I suspect that it may be related to imePadding() or the specific device/OS. Could you try applying imePadding() and WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE to a Composable outside of the bottom sheet to verify this?

dokar3 avatar Jun 13 '23 12:06 dokar3

Suppose that you are on a screen that has a texfield which is focused and the keyboard is open, and there is a button which opens a bottom sheet. when the keyboard is open and textfield is focused, on button click, bottom sheet expands and the keyboard gets closed. This is when this issue happens

rezafaraji93 avatar Jul 03 '23 07:07 rezafaraji93

Hmm... Tried a lot with the case where the keyboard is open before the sheet is expanded, but I still can't reproduce this issue on my device/emulator, need more time to investigate.

dokar3 avatar Jul 12 '23 03:07 dokar3