Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BringIntoViewRequester breaks screen with collapsible AppBar #326

Open
alaegin opened this issue Jan 23, 2023 · 1 comment
Open

BringIntoViewRequester breaks screen with collapsible AppBar #326

alaegin opened this issue Jan 23, 2023 · 1 comment
Labels
bug Something isn't working

Comments

@alaegin
Copy link

alaegin commented Jan 23, 2023

Hello!

Firstly, I'd like to say thank you to all of you, guys. A big work was done in this repository.

I found one issue with BringIntoViewRequester and the collapsible app bar.
I've modified TextFieldScreen sample from the repository: replaced its TopAppBar with TopAppBarLarge.

Then, if I click on any text field the scrollable Box animates its scroll to the clicked field (this is how BringIntoViewRequester works). But, the nested scroll doesn't handle it at all, and all scroll process results in broken UI:

Code

@Composable
internal fun TextFieldScreen(onNavigateUp: () -> Unit) {
    val scrollBehavior = TopAppBarScrollBehavior.exitUntilCollapsed()

    Scaffold(
        modifier = Modifier.nestedScroll(scrollBehavior.nestedScrollConnection),
        topBar = {
            TopAppBarLarge(
                title = { Text("Text Field") },
                onNavigateUp = onNavigateUp,
                scrollBehavior = scrollBehavior,
                largeElevated = false,
            )
        },
        backgroundColor = OrbitTheme.colors.surface.subtle,
        content = { contentPadding ->
            Box(
                Modifier
                    .fillMaxSize()
                    .verticalScroll(rememberScrollState())
                    .padding(contentPadding),
            ) {
                TextFieldScreenInner()
            }
        },
    )
}

Seems like we need to synchronize nested scroll with vertical scroll somehow. Do you have any ideas how to fix it?

@hrach hrach added the bug Something isn't working label Jan 24, 2023
@hrach
Copy link
Contributor

hrach commented Jan 24, 2023

Thanks for reporting this! It is not only an issue with "bringIntoViewRequester", but it can be reproduced by any explicit (animated) scroll on scrollState.

E.g. this doesn't work as well:

    val scrollBehavior = TopAppBarScrollBehavior.exitUntilCollapsed()
    val scrollState = rememberScrollState()
    
    LaunchedEffect(Unit) {
        scrollState.animateScrollTo(400)
    }
    Scaffold(
        modifier = Modifier.nestedScroll(scrollBehavior.nestedScrollConnection),

The only relevant thing I've found here seems to be work-as-intended:

Hi, thanks for reporting this. For now this is expected as nested scrolling is only activated through gesture based scrolling, not animation based scrolling. We do have plans to explore animation based nested scrolling in the future, so I'll keep you posted if things change. Closing this ticket for now as this is WAI.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants