Skip to content

feat: Add expandable-icon-end to collapsible side navigation - #4843

Open
jkuelz wants to merge 5 commits into
mainfrom
dev-v3-jkuelz-side-nav-icon-layout
Open

feat: Add expandable-icon-end to collapsible side navigation#4843
jkuelz wants to merge 5 commits into
mainfrom
dev-v3-jkuelz-side-nav-icon-layout

Conversation

@jkuelz

@jkuelz jkuelz commented Jul 29, 2026

Copy link
Copy Markdown
Member

Description

Adjusts the layout of the collapsible SideNavigation variant based on whether icons are present. When any nav item has an icon, the layout adapts: item spacing widens (separate PR #4831), the expand caret moves to the inline-end, and rows get a full-width hover background. Caret moves to end of the row to not clutter the left side when there are icons present, and hover is added to connect the caret and the text. Added an internal __expandIconPosition to the ExpandableSection component which is then used in SideNav.

Also included:

  • Fix: ExpandableSection's disableContentPaddings: Now removes content padding for all variants, not just container (other variants also have default content padding); API description corrected accordingly.
  • New design token: colorBackgroundSideNavigationItemIconHover -- it is a known issue that the hover token's dark 1T value isn't fully reference-token-themeable (won't track a primary-color change) — proper fix needs an alpha palette derived from primary, which is a larger change.
  • One-theme section headers: removed the section-header-specific typography overrides so section headers inherit the footer default (16px/500), to distinguish them from active expandable-link-groups.

Related links, issue #, if available: n/a

How has this been tested?

Dev pipeline (dev-v3-jkuelz)

Review checklist

The following items are to be evaluated by the author(s) and the reviewer(s).

Correctness

  • Changes include appropriate documentation updates.
  • Changes are backward-compatible if not indicated, see CONTRIBUTING.md.
  • Changes do not include unsupported browser features, see CONTRIBUTING.md.
  • Changes were manually tested for accessibility, see accessibility guidelines.

Security

Testing

  • Changes are covered with new/existing unit tests?
  • Changes are covered with new/existing integration tests?

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

jkuelz added 2 commits July 28, 2026 19:08
Add internal __expandIconPosition ('start' | 'end', default 'start') to
InternalExpandableSection. When 'end', the expand caret is DOM-reordered
to the inline-end (preserving focus order for accessibility) across all
variants; the outside-header caret (container and default-with-actions)
renders as an accessible button. Default 'start' behavior is unchanged
and there is no public API change (internal __-prefixed prop).

Groundwork for the side-navigation icon layout. Note: the navigation
variant now wraps its header text in a span (styled only in the end
layout), a minor DOM change for that side-nav-only variant.
 When any nav item has an icon, SideNavigation switches to an icon layout: the expand caret moves to the inline-end, item spacing widens, and rows get a full-width hover background. Consumes the existing withIcons signal and threads the internal __expandIconPosition to the Section and ExpandableLinkGroup expandable headers.

Also fixes ExpandableSection's  to remove content padding for all variants (previously only , despite other variants having default content padding) and corrects its docs. Adds a colorBackgroundSideNavigationItemIconHover design token.
@codecov

codecov Bot commented Jul 29, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.63%. Comparing base (e9c0c76) to head (feadac4).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #4843   +/-   ##
=======================================
  Coverage   97.63%   97.63%           
=======================================
  Files         957      957           
  Lines       31097    31132   +35     
  Branches    11434    11461   +27     
=======================================
+ Hits        30361    30396   +35     
+ Misses        729      689   -40     
- Partials        7       47   +40     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@jkuelz jkuelz changed the title feat: Add automatic icon layout to collapsible side navigation feat: Add expandable-icon-end to collapsible side navigation Jul 29, 2026
@jkuelz
jkuelz requested a review from mxschll July 29, 2026 03:42
@jkuelz
jkuelz marked this pull request as ready for review July 29, 2026 03:42
@jkuelz
jkuelz requested a review from a team as a code owner July 29, 2026 03:42
@mxschll

mxschll commented Jul 30, 2026

Copy link
Copy Markdown
Member

The collapsed-state behavior feels a bit inconsistent. When a parent has an icon, its children are not shown in the collapsed state:

Open Collapsed
image image

When the parent has no icon, the collapsed state shows children instead, but only the children that have icons:

Open Collapsed
image image

Is this the intended behavior?

My concern is that this could lead to confusing UX: two sections can behave differently in the collapsed state depending on whether the parent has an icon. In one case, the collapsed nav shows the parent; in another, it shows a subset of the children.

Would it be more intuitive to consistently show only parent items in the collapsed state? We could add a dev warning when a parent has no icon set or document in the guidelines that all parents should have icons.

Comment thread pages/side-navigation/collapsed.page.tsx
Comment thread style-dictionary/one-theme/colors.ts
Comment thread src/side-navigation/styles.scss Outdated
styles.content,
styles[`content-${baseVariant}`],
expanded && styles['content-expanded'],
disableContentPaddings && styles['disable-content-paddings']

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

disableContentPaddings existed before. Is this a breaking change?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DisableContentPaddings will still exist. The only part that is changing is that now disableContentPaddings applies to variants besides container. I view this more as a bug fix with a clear resolution rather than a breaking change. It might've only applied to the container variant because we didn't have use cases for the others, or the other variants didn't come with content padding (the previous description said, "default padding is only present for the container variant."). Which might've been true at the time, but is not true anymore.

Comment thread src/expandable-section/__tests__/expandable-section.test.tsx
expect(onChange).toHaveBeenCalledTimes(1);
});
});
});

@mxschll mxschll Jul 30, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we add a test that ensures the tab order is correct for link groups? When _expandIconPosition="start" it should be previous item -> caret -> link -> next item and when _expandIconPosition="end" it should be previous item -> link -> caret -> next item.

});

test('container variant toggles aria-expanded on click', () => {
const wrapper = renderInternalExpandableSection({ variant: 'container', __expandIconPosition: 'end' });

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a bug when opening / closing the section with Enter / Space, it opens and closes immediately. Clicking with the mouse works fine, because propagation is prevented for click events, not Enter / Space. We should fix that and have a test for it.

The focus behaves differently when __expandIconPosition: 'end'. With start, the whole header gets the focus. With end, you can tab onto the title, then on the trigger itself, but the trigger does not show a focus ring.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should also add this to the /expandable-section/container-variant.permutations and add integration tests for it.

lineHeightHeadingXs: '20px',
fontWeightHeadingXs: '500',

fontSideNavigationSectionHeaderSize: '14px',

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are we removing this? Can we set the values required for one-theme? Otherwise it'll fall back to vr again.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The desired is the same as VR (16px/500), which is why we are removing it.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we defined it here explicitly still? We'll have to untangle VR with One Theme at one point and keeping things separate makes it easier for us in the future.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can, but when we did VR, we only defined the items that were changed from the base theme. Which helped define the line between them, otherwise you're constantly going between the two to find a diff.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Non-blocking, but we should strive for making One Theme independent. Dependency on VR will cause issues should VR be deprecated in the distant future.

// Section groups
// ==========================================================================
.section-group {
@include styles.font-heading-m;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this change how section groups look? This affects all themes.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was redundant because we already use Box h3 variant in the parts.tsx file which would apply these styles by default.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants