fix(#3273): keep Side Menu Group open#3422
Conversation
There was a problem hiding this comment.
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
_openevent handler to only promote parent_current/_openwhen the child is current (and not overwrite parent state when the child is not current).
2d79615 to
5f23457
Compare
5f23457 to
bc6c91c
Compare
bc6c91c to
b43c771
Compare
✅ Deploy Preview for goa-design-2 ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
b43c771 to
93c1c92
Compare
93c1c92 to
842c87e
Compare
willcodeforcoffee
left a comment
There was a problem hiding this comment.
It seems to be working correctly now. LGTM 👍
|
@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; |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
@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:
- The Parent Group receives an
_openevent from Parent Link. The Group opens becausedetail.currentistrue. - The Parent Group receives an
_openevent from the Child Link. The Group closes again becausedetail.currentisfalse.
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.
|
Just waiting for changes that were discussed |
842c87e to
4511277
Compare
4511277 to
53afd64
Compare
|
@chrisolsen I amended my commit with the following changes:
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: I currently does the following...
But I think it should do the following:
Does that make sense? It's possible I don't understand the broader Side Menu event ecosystem. |
|
@bdfranck let's chat about this later today. |
53afd64 to
4d417ec
Compare
|
@chrisolsen I've amended my commit with the following changes to
This has the same effect as my original change but should be much clearer. Future enhancements that we discussed:
|
|
@ArakTaiRoth @willcodeforcoffee changes were made, so you guys might want to test things again; at least one of you. |
|
@chrisolsen This is good to be merged again |
|
🎉 This PR is included in version 1.41.0-dev.13 🎉 The release is available on: Your semantic-release bot 📦🚀 |
|
🎉 This PR is included in version 6.11.0-dev.9 🎉 The release is available on: Your semantic-release bot 📦🚀 |
|
🎉 This PR is included in version 4.11.0-dev.10 🎉 The release is available on: Your semantic-release bot 📦🚀 |
|
🎉 This PR is included in version 1.11.0-dev.4 🎉 The release is available on: Your semantic-release bot 📦🚀 |
|
🎉 This PR is included in version 2.0.0-next.1 🎉 The release is available on: Your semantic-release bot 📦🚀 |
|
🎉 This PR is included in version 2.0.0-next.1 🎉 The release is available on: Your semantic-release bot 📦🚀 |
|
🎉 This PR is included in version 7.0.0-next.1 🎉 The release is available on: Your semantic-release bot 📦🚀 |
|
🎉 This PR is included in version 5.0.0-next.1 🎉 The release is available on: Your semantic-release bot 📦🚀 |
|
🎉 This PR is included in version 2.0.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
|
🎉 This PR is included in version 7.0.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
|
🎉 This PR is included in version 5.0.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
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.
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.