Skip to content

ECHOES-1448 Auto-open SidebarNavigation accordions when a child item becomes active - #749

Open
david-cho-lerat-sonarsource wants to merge 1 commit into
mainfrom
david/ECHOES-1448-auto-open-sidebar-navigation-accordion-based-on-route
Open

ECHOES-1448 Auto-open SidebarNavigation accordions when a child item becomes active#749
david-cho-lerat-sonarsource wants to merge 1 commit into
mainfrom
david/ECHOES-1448-auto-open-sidebar-navigation-accordion-based-on-route

Conversation

@david-cho-lerat-sonarsource

@david-cho-lerat-sonarsource david-cho-lerat-sonarsource commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

Summary

  • add auto-open behavior to uncontrolled SidebarNavigation.AccordionItem
  • auto-open when any child item becomes active, including on the initial render
  • support both route-derived active state and explicit isActive on accordion child items
  • leave subsequent manual open/close interactions alone until a later child-active event
  • do not auto-close when active children become inactive
  • keep controlled accordions fully controlled and disable auto-open there

@netlify

netlify Bot commented Aug 11, 2026

Copy link
Copy Markdown

Deploy Preview for echoes-react ready!

Name Link
🔨 Latest commit 8479c18
🔍 Latest deploy log https://app.netlify.com/projects/echoes-react/deploys/6a7c6be57c38a10009a3302d
😎 Deploy Preview https://deploy-preview-749--echoes-react.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@hashicorp-vault-sonar-prod

hashicorp-vault-sonar-prod Bot commented Aug 11, 2026

Copy link
Copy Markdown

ECHOES-1448

Comment thread src/components/layout/sidebar-navigation/SidebarNavigationAccordionItem.tsx Outdated

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR enhances the Layout.SidebarNavigation.AccordionItem (uncontrolled mode) so it automatically opens when one of its child items becomes active (via routing match or explicit isActive). It introduces an opt-out prop to preserve the previous “stay closed unless user opens it” behavior when needed.

Changes:

  • Added auto-open-on-active-child behavior for uncontrolled SidebarNavigationAccordionItem, with an opt-out via disableAutoOpenOnActiveItem.
  • Introduced an internal SidebarNavigationAccordionContext so child items can report active-state changes to the parent accordion.
  • Updated SidebarNavigationAccordionChildItem and expanded test + Storybook coverage for route-driven and explicit active states.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.

Show a summary per file
File Description
stories/layout/sidebar-navigation/SidebarNavigationAccordionItem-stories.tsx Adds Storybook examples for auto-open and opt-out behavior.
src/components/layout/sidebar-navigation/SidebarNavigationAccordionItem.tsx Implements uncontrolled auto-open logic and provides the context handler to children.
src/components/layout/sidebar-navigation/SidebarNavigationAccordionContext.ts New internal context to propagate child “auto-open key” changes to the accordion.
src/components/layout/sidebar-navigation/SidebarNavigationAccordionChildItem.tsx Reports active/route-match changes to the accordion when context is present.
src/components/layout/sidebar-navigation/index.ts Re-exports child item props and documents the new uncontrolled auto-open behavior.
src/components/layout/sidebar-navigation/tests/SidebarNavigationAccordionItem-test.tsx Adds coverage for auto-open, opt-out, controlled behavior, and navigation-driven state transitions.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@david-cho-lerat-sonarsource
david-cho-lerat-sonarsource force-pushed the david/ECHOES-1448-auto-open-sidebar-navigation-accordion-based-on-route branch 2 times, most recently from 080a0b0 to 19680b5 Compare August 11, 2026 13:17
@david-cho-lerat-sonarsource
david-cho-lerat-sonarsource force-pushed the david/ECHOES-1448-auto-open-sidebar-navigation-accordion-based-on-route branch 2 times, most recently from 9357280 to a646b06 Compare August 11, 2026 13:21
Comment thread src/components/layout/sidebar-navigation/SidebarNavigationAccordionItem.tsx Outdated
@david-cho-lerat-sonarsource
david-cho-lerat-sonarsource force-pushed the david/ECHOES-1448-auto-open-sidebar-navigation-accordion-based-on-route branch 2 times, most recently from 5a6652f to 6a2bf8a Compare August 11, 2026 13:53
@david-cho-lerat-sonarsource
david-cho-lerat-sonarsource marked this pull request as ready for review August 11, 2026 14:01

@jeremy-davis-sonarsource jeremy-davis-sonarsource left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I wonder if we can't make it a bit easier to follow by extracting more parts in a hook (or the context, even?)

Comment thread src/components/layout/sidebar-navigation/SidebarNavigationAccordionChildItem.tsx Outdated
Comment thread src/components/layout/sidebar-navigation/SidebarNavigationAccordionItem.tsx Outdated
@david-cho-lerat-sonarsource
david-cho-lerat-sonarsource force-pushed the david/ECHOES-1448-auto-open-sidebar-navigation-accordion-based-on-route branch 2 times, most recently from a8f6195 to 6ffe70a Compare August 12, 2026 07:45
@david-cho-lerat-sonarsource

Copy link
Copy Markdown
Contributor Author

I wonder if we can't make it a bit easier to follow by extracting more parts in a hook (or the context, even?)

I've introduced a hook for the parent item, it didn't seem worth it for the child

@david-cho-lerat-sonarsource
david-cho-lerat-sonarsource force-pushed the david/ECHOES-1448-auto-open-sidebar-navigation-accordion-based-on-route branch from 6ffe70a to 2a725fd Compare August 12, 2026 08:07
@david-cho-lerat-sonarsource

This comment was marked as outdated.

@david-cho-lerat-sonarsource
david-cho-lerat-sonarsource force-pushed the david/ECHOES-1448-auto-open-sidebar-navigation-accordion-based-on-route branch from 2a725fd to 41ae718 Compare August 12, 2026 09:40
@david-cho-lerat-sonarsource
david-cho-lerat-sonarsource force-pushed the david/ECHOES-1448-auto-open-sidebar-navigation-accordion-based-on-route branch from 41ae718 to 8479c18 Compare August 12, 2026 12:49
@gitar-bot

This comment was marked as outdated.

@sonarqube-next

Copy link
Copy Markdown

@jeremy-davis-sonarsource jeremy-davis-sonarsource left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks great!

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.

3 participants