Skip to content

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

TypeScript

fix(core): drop empty SideNav footer container when collapsible.hasButton is false (#3609)

dmitriy-bty549e44f94152
diff --git a/.changeset/sidenav-hasbutton-empty-footer.md b/.changeset/sidenav-hasbutton-empty-footer.md
new file mode 100644
index 0000000000..3a691a01bd
--- /dev/null
+++ b/.changeset/sidenav-hasbutton-empty-footer.md
@@ -0,0 +1,6 @@
+---
+'@astryxdesign/core': patch
+---
+
+[fix] SideNav: don't render the empty sticky-bottom container when `collapsible.hasButton` is false. Previously the footer container rendered whenever the sidebar was collapsible — even with the built-in button opted out and no `footer`/`footerIcons` — leaving an empty, bordered container at the bottom of the nav. The container now renders only when it has visible content (a footer, footer icons, or the built-in collapse button). (#3603)
+@dmitriy-bty
diff --git a/packages/core/src/SideNav/SideNav.test.tsx b/packages/core/src/SideNav/SideNav.test.tsx
index bb32f7722a..6c75c34105 100644
--- a/packages/core/src/SideNav/SideNav.test.tsx
+++ b/packages/core/src/SideNav/SideNav.test.tsx
@@ -162,6 +162,26 @@ describe('SideNav', () => {
screen.getByRole('button', {name: 'Expand sidebar'}),
).toBeInTheDocument();
});
+
+ it('does not render an empty footer container when collapsible.hasButton is false', () => {
+ render(
+ <SideNav data-testid="nav" collapsible={{hasButton: false}}>
+ Content
+ </SideNav>,
+ );
+
+ // The built-in collapse button is opted out (consumers render their own
+ // SideNavCollapseButton in the header), so it must not appear...
+ expect(
+ screen.queryByRole('button', {name: 'Collapse sidebar'}),
+ ).not.toBeInTheDocument();
+
+ // ...and no empty sticky-bottom container should be left behind. With no
+ // footer/footerIcons and no built-in button, the scrollable content region
+ // is the nav's only child.
+ const nav = screen.getByTestId('nav');
+ expect(nav.children).toHaveLength(1);
+ });
});
// =============================================================================
diff --git a/packages/core/src/SideNav/SideNav.tsx b/packages/core/src/SideNav/SideNav.tsx
index 2d512fe440..ddf4ea8369 100644
--- a/packages/core/src/SideNav/SideNav.tsx
+++ b/packages/core/src/SideNav/SideNav.tsx
@@ -490,6 +490,10 @@ export function SideNav({
// =========================================================================
const hasStickyTop = !!(header || topContent);
const hasStickyBottom = !!(footer || footerIcons);
+ // The built-in collapse button only renders when collapse is enabled and it
+ // hasn't been opted out via `collapsible.hasButton: false` (e.g. when the
+ // consumer places a SideNavCollapseButton in the header instead).
+ const showCollapseButton = isCollapsible && hasCollapseButton;
// When resizable, override the nav width via inline style
const resizableNavStyle: React.CSSProperties | undefined = isResizable
@@ -532,7 +536,7 @@ export function SideNav({
)}>
{children}
</div>
- {(hasStickyBottom || isCollapsible) && (
+ {(hasStickyBottom || showCollapseButton) && (
<div
{...stylex.props(
styles.stickyBottom,
@@ -544,7 +548,7 @@ export function SideNav({
styles.footerRow,
collapsed && styles.footerRowCollapsed,
)}>
- {isCollapsible && hasCollapseButton && <SideNavCollapseButton />}
+ {showCollapseButton && <SideNavCollapseButton />}
{footerIcons}
</div>
</div>