Skip to content

fix(#3273): keep Side Menu Group open#3422

Merged
chrisolsen merged 1 commit intodevfrom
benji/3273-side-menu-group-stays-open
Mar 6, 2026
Merged

fix(#3273): keep Side Menu Group open#3422
chrisolsen merged 1 commit intodevfrom
benji/3273-side-menu-group-stays-open

Conversation

@bdfranck
Copy link
Copy Markdown
Collaborator

@bdfranck bdfranck commented Feb 12, 2026

Before

When a parent Side Menu Group is current and open,
But a child Group is not current or open,
The parent group will be closed.

menu-group-broken

After

When a parent Side Menu Group is current and open,
But a child Side Menu Group is not current or open,
The parent Group is still current and open.

menu-group-fixed

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Fixes nested goa-side-menu-group state propagation so a parent group that is already current/open is not incorrectly closed when a child group reports itself as non-current. This aligns Side Menu Group open behavior with expected navigation highlighting.

Changes:

  • Update the child _open event handler to only promote parent _current/_open when the child is current (and not overwrite parent state when the child is not current).

Copy link
Copy Markdown
Contributor

Copilot AI commented Feb 13, 2026

@bdfranck I've opened a new pull request, #3426, to work on those changes. Once the pull request is ready, I'll request review from you.

@GovAlta GovAlta deleted a comment from Copilot AI Feb 13, 2026
@bdfranck bdfranck force-pushed the benji/3273-side-menu-group-stays-open branch from 5f23457 to bc6c91c Compare February 13, 2026 23:29
@bdfranck bdfranck linked an issue Feb 13, 2026 that may be closed by this pull request
@bdfranck bdfranck requested a review from ArakTaiRoth February 17, 2026 16:11
Comment thread apps/prs/react/src/app/app.tsx
Comment thread apps/prs/react/src/app/app.tsx
Comment thread libs/web-components/src/components/side-menu-group/SideMenuGroup.svelte Outdated
Comment thread apps/prs/react/src/routes/bugs/bug3273.tsx
@bdfranck bdfranck force-pushed the benji/3273-side-menu-group-stays-open branch from bc6c91c to b43c771 Compare February 18, 2026 22:21
@netlify
Copy link
Copy Markdown

netlify Bot commented Feb 18, 2026

Deploy Preview for goa-design-2 ready!

Name Link
🔨 Latest commit 4d417ec
🔍 Latest deploy log https://app.netlify.com/projects/goa-design-2/deploys/69a9ed59d9fdf10008e0e44b
😎 Deploy Preview https://deploy-preview-3422--goa-design-2.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

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

@bdfranck bdfranck force-pushed the benji/3273-side-menu-group-stays-open branch from b43c771 to 93c1c92 Compare February 18, 2026 22:22
@bdfranck bdfranck requested a review from ArakTaiRoth February 18, 2026 22:50
Comment thread apps/prs/react/src/main.tsx Outdated
Comment thread libs/react-components/specs/side-menu.browser.spec.tsx Outdated
@bdfranck bdfranck force-pushed the benji/3273-side-menu-group-stays-open branch from 93c1c92 to 842c87e Compare February 19, 2026 22:37
Copy link
Copy Markdown
Collaborator

@willcodeforcoffee willcodeforcoffee left a comment

Choose a reason for hiding this comment

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

It seems to be working correctly now. LGTM 👍

@ArakTaiRoth
Copy link
Copy Markdown
Collaborator

@chrisolsen This is good to be merged

// listen to events by children (if child is open the parent also has to be open)
_rootEl.addEventListener("_open", (e: Event) => {
_open = _current = (e as CustomEvent).detail.current;
if ((e as CustomEvent).detail.current) _current = _open = true;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Is there a reason that this change was made. It seems to do the same thing...am I missing something?

Then again if we are receiving an _open event, then wouldn't we just always set _current and _open to true?

Copy link
Copy Markdown
Collaborator Author

@bdfranck bdfranck Feb 24, 2026

Choose a reason for hiding this comment

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

@chrisolsen Here's how the bug was happening. If we have an embedded group like the one below...

<GoabSideMenu>
  <GoabSideMenuGroup heading="Parent Group">
    <Link to="/parent">Parent Link</Link>
    <GoabSideMenuGroup heading="Child Group">
      <Link to="/child">Child Link</Link>
    </GoabSideMenuGroup>
  </GoabSideMenuGroup>
</GoabSideMenu>

...the Parent Group receives two _open events. So when the Parent Link is current, the following happens oh load:

  1. The Parent Group receives an _open event from Parent Link. The Group opens because detail.current is true.
  2. The Parent Group receives an _open event from the Child Link. The Group closes again because detail.current is false.

But we never need to close a group because it's closed by default. My change only opens a group if details.current is true. It does nothing when it is false.

Is there a better way to address this? Have I neglected to consider other scenarios? I'm happy to chat about it if you have further questions.

@chrisolsen
Copy link
Copy Markdown
Collaborator

Just waiting for changes that were discussed

@bdfranck bdfranck force-pushed the benji/3273-side-menu-group-stays-open branch from 842c87e to 4511277 Compare March 5, 2026 15:33
@bdfranck bdfranck requested a review from chrisolsen March 5, 2026 15:33
@bdfranck bdfranck force-pushed the benji/3273-side-menu-group-stays-open branch from 4511277 to 53afd64 Compare March 5, 2026 15:41
@bdfranck
Copy link
Copy Markdown
Collaborator Author

bdfranck commented Mar 5, 2026

@chrisolsen I amended my commit with the following changes:

  • Added a _senderEl outside the _rootEl
  • Changed events to dispatch from _senderEl

This reduced the number of events received but doesn't appear to fix the problem. I still think there's an issue with this function:

// listen to events by children (if child is open the parent also has to be open)
_rootEl.addEventListener("_open", (e: Event) => {
_open = _current = (e as CustomEvent).detail.current;
});
}

I currently does the following...

  1. Open the parent group if the child group is open.
  2. Close the parent group if the child group is closed.

But I think it should do the following:

  1. Open the parent group if the child group is open.
  2. Close the parent group if the child group is closed AND the parent does not have a current menu item.

Does that make sense? It's possible I don't understand the broader Side Menu event ecosystem.

@chrisolsen
Copy link
Copy Markdown
Collaborator

@bdfranck let's chat about this later today.

@bdfranck bdfranck force-pushed the benji/3273-side-menu-group-stays-open branch from 53afd64 to 4d417ec Compare March 5, 2026 20:53
@bdfranck
Copy link
Copy Markdown
Collaborator Author

bdfranck commented Mar 5, 2026

@chrisolsen I've amended my commit with the following changes to SideMenuGroup.svelte:

  • Re-named the notifyParent function to dispatchGroupOpen
  • Child group only dispatches _open when the group is open
  • Removed the current boolean from the _open event
  • When a parent group receives _open it always sets open to true

This has the same effect as my original change but should be much clearer.

Future enhancements that we discussed:

  • Further reducing redundant events
  • Keeping a group open when switching to a different nav item in a sibling group.

@chrisolsen chrisolsen requested a review from ArakTaiRoth March 5, 2026 21:11
@chrisolsen
Copy link
Copy Markdown
Collaborator

@ArakTaiRoth @willcodeforcoffee changes were made, so you guys might want to test things again; at least one of you.

Copy link
Copy Markdown
Collaborator

@willcodeforcoffee willcodeforcoffee left a comment

Choose a reason for hiding this comment

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

✅ LGTM!

@ArakTaiRoth
Copy link
Copy Markdown
Collaborator

@chrisolsen This is good to be merged again

@chrisolsen chrisolsen merged commit 374dc31 into dev Mar 6, 2026
8 checks passed
@chrisolsen chrisolsen deleted the benji/3273-side-menu-group-stays-open branch March 6, 2026 16:24
@chrisolsen
Copy link
Copy Markdown
Collaborator

🎉 This PR is included in version 1.41.0-dev.13 🎉

The release is available on:

Your semantic-release bot 📦🚀

@chrisolsen
Copy link
Copy Markdown
Collaborator

🎉 This PR is included in version 6.11.0-dev.9 🎉

The release is available on:

Your semantic-release bot 📦🚀

@chrisolsen
Copy link
Copy Markdown
Collaborator

🎉 This PR is included in version 4.11.0-dev.10 🎉

The release is available on:

Your semantic-release bot 📦🚀

@chrisolsen
Copy link
Copy Markdown
Collaborator

🎉 This PR is included in version 1.11.0-dev.4 🎉

The release is available on:

Your semantic-release bot 📦🚀

@chrisolsen
Copy link
Copy Markdown
Collaborator

🎉 This PR is included in version 2.0.0-next.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

@chrisolsen
Copy link
Copy Markdown
Collaborator

🎉 This PR is included in version 2.0.0-next.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

@chrisolsen
Copy link
Copy Markdown
Collaborator

🎉 This PR is included in version 7.0.0-next.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

@chrisolsen
Copy link
Copy Markdown
Collaborator

🎉 This PR is included in version 5.0.0-next.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

@chrisolsen
Copy link
Copy Markdown
Collaborator

🎉 This PR is included in version 2.0.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@chrisolsen chrisolsen added the released Released into production. label Apr 1, 2026
@chrisolsen
Copy link
Copy Markdown
Collaborator

🎉 This PR is included in version 7.0.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@chrisolsen
Copy link
Copy Markdown
Collaborator

🎉 This PR is included in version 5.0.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SideMenuGroup doesn't stay open

6 participants