JetBrains / compose-multiplatform

Compose Multiplatform, a modern UI framework for Kotlin that makes building performant and beautiful user interfaces easy and enjoyable.
https://jetbrains.com/lp/compose-multiplatform
Apache License 2.0
15.9k stars 1.16k forks source link

[Desktop] HorizontalPager scroll offsets in the middle of two pages after window resize #3272

Open arkivanov opened 1 year ago

arkivanov commented 1 year ago

Describe the bug

HorizontalPager partially displays two pages after selecting the second page and resizing the window bigger.

Affected platforms Desktop

If the bug is Android-only, report it in the Jetpack Compose tracker

Versions

To Reproduce

@OptIn(ExperimentalFoundationApi::class)
@Composable
fun SomePages() {
    val state = rememberPagerState()
    val scope = rememberCoroutineScope()

    Column {
        Button(
            onClick = {
                scope.launch {
                    state.scrollToPage(1)
                }
            }
        ) { Text("Click") }

        HorizontalPager(
            pageCount = 2,
            modifier = Modifier.fillMaxSize(),
            state = state,
        ) { index ->
            when (index) {
                0 -> Box(modifier = Modifier.fillMaxSize().background(Color.Red))
                1 -> Box(modifier = Modifier.fillMaxSize().background(Color.Blue))
            }
        }
    }
}

Actual behavior Both pages are partially visible on the screen.

Expected behavior The second page remains expanded to the whole screen.

Screenshots

https://github.com/JetBrains/compose-multiplatform/assets/26204457/737a9ab8-7e82-4b8b-8d8e-200406761e67

fluxxion82 commented 1 year ago

I see something very similar when using a Scaffold with a Drawer; when I resize the window bigger the drawer contents will appear.

okushnikov commented 2 months ago

Please check the following ticket on YouTrack for follow-ups to this issue. GitHub issues will be closed in the coming weeks.