Skip to content

An open source design system that's fully customizable and agent ready

TypeScript

fix(AppShell): keep auto section header solid (#5873)

Cindy Zhang701fd39bdde3
diff --git a/.changeset/appshell-auto-header-background.md b/.changeset/appshell-auto-header-background.md
new file mode 100644
index 0000000000..9d66d93f16
--- /dev/null
+++ b/.changeset/appshell-auto-header-background.md
@@ -0,0 +1,7 @@
+---
+'@astryxdesign/core': patch
+---
+
+[fix] Keep AppShell's section top bar solid in auto-height mode while content scrolls beneath it.
+
+@cixzhang
diff --git a/packages/core/src/AppShell/AppShell.test.tsx b/packages/core/src/AppShell/AppShell.test.tsx
index 49a9bf6864..a73cad392b 100644
--- a/packages/core/src/AppShell/AppShell.test.tsx
+++ b/packages/core/src/AppShell/AppShell.test.tsx
@@ -579,6 +579,27 @@ describe('AppShell', () => {
).toBeDefined();
});
+ it('renders an opaque section header only in auto mode', () => {
+ const {rerender} = render(
+ <AppShell height="auto" variant="section" topNav={<div>Nav</div>}>
+ <div>Content</div>
+ </AppShell>,
+ );
+
+ expect(
+ getComputedStyle(screen.getByRole('banner')).backgroundColor,
+ ).not.toBe('rgba(0, 0, 0, 0)');
+
+ rerender(
+ <AppShell height="fill" variant="section" topNav={<div>Nav</div>}>
+ <div>Content</div>
+ </AppShell>,
+ );
+ expect(getComputedStyle(screen.getByRole('banner')).backgroundColor).toBe(
+ 'rgba(0, 0, 0, 0)',
+ );
+ });
+
it('does not apply sticky wrapper in fill mode', () => {
render(
<AppShell
diff --git a/packages/core/src/AppShell/AppShell.tsx b/packages/core/src/AppShell/AppShell.tsx
index 5e442434bd..7de90d7c01 100644
--- a/packages/core/src/AppShell/AppShell.tsx
+++ b/packages/core/src/AppShell/AppShell.tsx
@@ -555,6 +555,11 @@ export function AppShell({
: variant === 'surface'
? styles.navAreaSurface
: undefined;
+ // Section normally inherits the shell's surface background. Its auto-height
+ // header needs to paint that surface itself while content scrolls beneath it.
+ const headerAreaStyle =
+ navAreaStyle ??
+ (isAuto && variant === 'section' ? styles.navAreaSurface : undefined);
const contentAreaStyle =
variant === 'wash'
? styles.contentBgWash
@@ -685,7 +690,7 @@ export function AppShell({
role="banner"
{...mergeProps(
themeProps('app-shell-header', {variant}),
- stylex.props(navAreaStyle, isAuto && styles.headerSticky),
+ stylex.props(headerAreaStyle, isAuto && styles.headerSticky),
)}>
{headerInner}
</div>
@@ -774,7 +779,7 @@ export function AppShell({
role={headerContent == null ? 'banner' : undefined}
{...mergeProps(
themeProps('app-shell-header', {variant}),
- stylex.props(navAreaStyle, isAuto && styles.headerSticky),
+ stylex.props(headerAreaStyle, isAuto && styles.headerSticky),
)}>
<LayoutHeader padding={0} hasDivider={navHasDividers}>
<div