fix: expand/collapse all groups now works with nested groups#6792
Conversation
There was a problem hiding this comment.
Pull request overview
This PR fixes the expand/collapse all groups functionality to work correctly with nested group hierarchies at any depth level. Previously, the feature only worked with root-level groups.
Changes:
- Updated
groupMonitorscomputed property to include all groups with children at any nesting level by removing theparent === nullfilter - Added automatic navigation to root parent group when collapsing all groups while viewing a nested group
- Enhanced UX by preventing users from being stuck in collapsed nested groups
|
Added infinite loop protection with |
CommanderStorm
left a comment
There was a problem hiding this comment.
LGTM.
Could you revert the copilot suggestion? I think we need to fix this in the validation step instead.
src/components/MonitorList.vue
Outdated
| const visited = new Set(); | ||
| let rootParentId = currentMonitor.parent; | ||
| let rootParent = this.$root.monitorList[rootParentId]; | ||
| const MAX_TRAVERSAL_STEPS = 1000; | ||
| let safetyCounter = 0; | ||
|
|
||
| while ( | ||
| rootParent && | ||
| rootParent.parent !== null && | ||
| !visited.has(rootParentId) && | ||
| safetyCounter < MAX_TRAVERSAL_STEPS | ||
| ) { | ||
| visited.add(rootParentId); | ||
| rootParentId = rootParent.parent; | ||
| rootParent = this.$root.monitorList[rootParentId]; | ||
| safetyCounter++; | ||
| } | ||
|
|
There was a problem hiding this comment.
If circular groups are possible (have not checked, they might), this is a bug.
Let's not add handling for potential bugs in the frontend and simplify this to your OG version of this.
|
thanks ❤️ |
Summary
In this pull request, the following changes are made:
groupMonitorscomputed property was updated to include all groups with children, regardless of their nesting level, by removing theparent === nullfilterI tested this by reproducing the scenario shown in the video from the issue, and the expand/collapse functionality now works correctly with nested groups at all levels.
Please test on your side and tell me if and don't hesitate to tell me if I've forgotten anything.
Please follow this checklist to avoid unnecessary back and forth (click to expand)
I understand that I am responsible for and able to explain every line of code I submit.
Screenshots for Visual Changes
UPDOWN