Skip to content

Fix scrollBehavior in Material3TopAppBarOptions#291

Merged
marcprux merged 1 commit intoskiptools:mainfrom
dfabulich:fix-scroll-behavior-app-bar-options
Jan 6, 2026
Merged

Fix scrollBehavior in Material3TopAppBarOptions#291
marcprux merged 1 commit intoskiptools:mainfrom
dfabulich:fix-scroll-behavior-app-bar-options

Conversation

@dfabulich
Copy link
Contributor

Fixes #290

The readme documents a way to customize the Material 3 top app bar provided by SkipUI's NavigationStack.

extension View {
    public func material3TopAppBar(_ options: @Composable (Material3TopAppBarOptions) -> Material3TopAppBarOptions) -> some View
}

public struct Material3TopAppBarOptions {
    public var title: @Composable () -> Void
    public var modifier: androidx.compose.ui.Modifier
    public var navigationIcon: @Composable () -> Void
    public var colors: androidx.compose.material3.TopAppBarColors
    public var scrollBehavior: androidx.compose.material3.TopAppBarScrollBehavior?
    public var preferCenterAlignedStyle: Bool
    public var preferLargeStyle: Bool
}

But one of these options is not like the others: scrollBehavior requires coordination between the top app bar and its Column container, via a modifier.nestedScroll(scrollBehavior.nestedScrollConnection).

Prior to this PR, the scroll connection was being passed to the TopAppBar after the default nestedScrollConnection was attached to the column's modifier, failing to connect the user-provided scrollBehavior's nestedScrollConnection to the Column. Now, we're extracting the user-provided scrollBehavior early, so we can pass its nestedScrollConnection to the column.

Skip Pull Request Checklist:

  • REQUIRED: I have signed the Contributor Agreement
  • REQUIRED: I have tested my change locally with swift test
  • OPTIONAL: I have tested my change on an iOS simulator or device
  • OPTIONAL: I have tested my change on an Android emulator or device

@cla-bot cla-bot bot added the cla-signed label Jan 5, 2026
@marcprux marcprux requested review from aabewhite and marcprux and removed request for aabewhite January 5, 2026 05:07
@marcprux marcprux merged commit fd5ae49 into skiptools:main Jan 6, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

.material3TopAppBar allows setting scrollBehavior, but it doesn't work

2 participants