Anyone else seeing incorrect bottom padding after ...
# compose-ios
m
Anyone else seeing incorrect bottom padding after rotating screen from landscape to portrait with keyboard open (iPhone 16e)? Here’s the logging: 1. rotate screen from landscape to portrait with keyboard open
Copy code
safeDrawing.bottom: 984
... <repeated values> ...
safeDrawing.bottom: 984
safeDrawing.bottom: 1005
as expected, keyboard is hidden. However, bottom padding remains. 2. tap on text field to open soft keyboard
Copy code
safeDrawing.bottom: 102
... <smooth progression> ...
safeDrawing.bottom: 1005
3. close soft keyboard
Copy code
safeDrawing.bottom: 990
... <smooth progression> ...
safeDrawing.bottom: 102
now correct padding shows.
w
I tried switching from landscape to portrait while the keyboard was open, and it didn’t get hidden. I’m using composeMultiplatform = "1.10.0". & ios 26.2 with iphone17
m
Thanks for trying out. Yes, it seems dependent on the layout. I currently have a working workaround that checks ime visibility and uses that to override the padding.
@wwalkingg can you confirm whether your content is drawing behind the keyboard?
For me, the issue started when I moved my text field from the top of the screen to the bottom (directly above the keyboard, if visible)
w
Do you want your TextField to be covered by the keyboard?
m
No, it sits directly before the keyboard. And it works fine except for this rotation issue.
👀 1
w
ScreenRecording_02-28-2026 14-09-20_1.MP4
ScreenRecording_02-28-2026 14-11-05_1.MP4
m
Interesting, your keyboard stays visible whereas mine does not. So I guess that’s the problem. Some kind of state where the keyboard is no longer shown but the padding thinks it still is. In other words, the problem is rather that the keyboard should still be showing (but isn’t) and not that the padding is wrong.
w
I think your understanding is correct; now we need to figure out why the keyboard disappears.
It would be best to have a minimal reproducible example so that I can help you determine whether it’s a code issue or a device issue.
👍 1
m
In my old layout it was less of an issue because I was drawing behind the keyboard, and so you’d end up with extra bottom content padding, which wasn’t a big issue.
w
Or you could try running the following code on your device.
Copy code
MaterialTheme {
    val softwareKeyboardController = LocalSoftwareKeyboardController.current
    var showContent by remember { mutableStateOf(false) }
    Column(
        modifier = Modifier
            .fillMaxSize()
            .safeDrawingPadding()
            .background(MaterialTheme.colorScheme.primaryContainer)
            .border(1.dp, Color.Black),
        horizontalAlignment = Alignment.CenterHorizontally,
        verticalArrangement = Arrangement.Bottom
    ) {
        TextField(
            value = "${WindowInsets.ime.getBottom(LocalDensity.current)}",
            onValueChange = {}
        )
        Button(
            onClick = { softwareKeyboardController?.hide() }
        ) { Text("Close") }
    }
}
m
Okay so the issue is caused by having different layouts for landscape vs portrait. Even if I use
movableContentOf
to preserve the
TextField
state:
Copy code
val textField = remember {
        movableContentOf {
            TextField(
                value = "${WindowInsets.ime.getBottom(LocalDensity.current)}",
                onValueChange = {}
            )
        }
    }
    Column(
        modifier = Modifier
            .fillMaxSize()
            .safeDrawingPadding()
            .background(MaterialTheme.colorScheme.primaryContainer)
            .border(1.dp, Color.Black),
        horizontalAlignment = Alignment.CenterHorizontally,
        verticalArrangement = Arrangement.Bottom
    ) {
        if (isLandscape()) {
            textField()
        } else {
            // normally would have a different layout, but even with the same composable, the issue occurs
            textField()
        }
    }
Copy code
@Composable
fun isLandscape(): Boolean {
    val containerSize = LocalWindowInfo.current.containerSize
    return containerSize.width > containerSize.height
}
This also demonstrates a related UI glitch issue (see end of video) where the screen goes into a never-ending spasm.
ScreenRecording_02-28-2026 14-27-11_1.MP4
w
If it’s a clean project, then it’s probably a device issue – does the keyboard in your email app automatically hide when you rotate the screen?
m
Did you try my code?
w
@Mark It seems to be a code issue—I just tried it and it's exactly the same as yours. It looks like the TextField has lost its focus state.
m
Thanks for confirming. I’m surprised this hasn’t piqued the interest of some of the Jetbrains guys.
a
Hi folks! Thank you for the investigation. Could you please file an issue in our YouTrack attaching the reproducer?