Skip to content

fix(s2-docs): auto-scroll and expand section for group selected nav link#9664

Open
domhhv wants to merge 1 commit intoadobe:mainfrom
domhhv:fix/s2-docs-nav-auto-scroll-group-selected-link
Open

fix(s2-docs): auto-scroll and expand section for group selected nav link#9664
domhhv wants to merge 1 commit intoadobe:mainfrom
domhhv:fix/s2-docs-nav-auto-scroll-group-selected-link

Conversation

@domhhv
Copy link

@domhhv domhhv commented Feb 15, 2026

Closes #9663

✅ Pull Request Checklist:

  • Included link to corresponding React Spectrum GitHub Issue.
  • Added/updated unit tests and storybook for this change (for new code or code which already has tests).
  • Filled out test instructions.
  • Updated documentation (if it already exists for this component).
  • Looked at the Accessibility Practices for this feature - Aria Practices

📝 Test Instructions:

Current behaviour (prod):

Screen.Recording.2026-02-15.at.19.36.53.mov

Ideal behaviour (this changeset):

Screen.Recording.2026-02-15.at.19.38.06.mov

Summary of changes needed for this in packages/dev/s2-docs/src/Nav.tsx:

  1. Auto-expand disclosure when the current page's group, not only section, matches the nav section name
  2. Auto-scroll the selected SideNavLink into view on mount
  3. Add scrollMarginTop to prevent the link from being hidden behind the fixed header
  4. Add type annotation to linkRef to pass TypeScript checks

🧢 Your Project:

https://github.com/domhhv/habitrack

Copy link
Member

@snowystinger snowystinger left a comment

Choose a reason for hiding this comment

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

Thanks for the PR, just a minor note

return;
}

linkRef.current.scrollIntoView({block: 'start', behavior: 'smooth'});
Copy link
Member

Choose a reason for hiding this comment

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

I think we'll want to use our scrollIntoViewport from @react-aria/utils

This way it'll only scroll into view if it's currently out of view and it'll fix some issues across browsers.

@snowystinger
Copy link
Member

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.

S2-docs: Internationalized section does not expand on its nested group link page load

2 participants