An open source design system that's fully customizable and agent ready
TypeScript
fix(SideNav): center footer content when collapsed (#4852)
Ojas Mutreja1e14f3c31f65
diff --git a/.changeset/sidenav-footer-collapsed-centering.md b/.changeset/sidenav-footer-collapsed-centering.mdnew file mode 100644index 0000000000..fab93a8f5a--- /dev/null+++ b/.changeset/sidenav-footer-collapsed-centering.md@@ -0,0 +1,7 @@+---+'@astryxdesign/core': patch+---++[fix] SideNav: `footer` content now centers when the nav is collapsed, matching how `children` already centers. `stickyBottomCollapsed` (the collapsed-rail wrapper for `footer`) was missing `alignItems: 'center'`, which its sibling `scrollableCollapsed` (the collapsed-rail wrapper for `children`) already had — so full-width footer content (e.g. an icon-only button) stretched to the collapsed rail's width instead of centering.++@HelloOjasMutrejadiff --git a/packages/core/src/SideNav/SideNav.test.tsx b/packages/core/src/SideNav/SideNav.test.tsxindex 063aba4a15..27a2839866 100644--- a/packages/core/src/SideNav/SideNav.test.tsx+++ b/packages/core/src/SideNav/SideNav.test.tsx@@ -183,6 +183,27 @@ describe('SideNav', () => {expect(nav.children).toHaveLength(1);});+ it('centers footer content when collapsed, matching children alignment', () => {+ render(+ <SideNav+ data-testid="nav"+ collapsible={{isCollapsed: true, hasButton: false}}+ footer={<span data-testid="footer-content">F</span>}>+ <span data-testid="children-content">C</span>+ </SideNav>,+ );++ // scrollableCollapsed (wraps children) and stickyBottomCollapsed (wraps+ // footer) are structurally parallel collapsed-rail containers; both+ // must center their content the same way, or full-width footer content+ // stretches to the collapsed rail's width instead of centering.+ const childrenContainer =+ screen.getByTestId('children-content').parentElement;+ const footerContainer = screen.getByTestId('footer-content').parentElement;+ expect(getComputedStyle(childrenContainer!).alignItems).toBe('center');+ expect(getComputedStyle(footerContainer!).alignItems).toBe('center');+ });+it('fires a consumer onClick on the collapse button in addition to toggling', async () => {const user = userEvent.setup();const onClick = vi.fn();diff --git a/packages/core/src/SideNav/SideNav.tsx b/packages/core/src/SideNav/SideNav.tsxindex 76f32cd5fc..439d654208 100644--- a/packages/core/src/SideNav/SideNav.tsx+++ b/packages/core/src/SideNav/SideNav.tsx@@ -143,6 +143,7 @@ const styles = stylex.create({},stickyBottomCollapsed: {paddingBlockStart: 0,+ alignItems: 'center',},// Drawer footer — pushed to bottom of the scrollable content areadrawerFooter: {