Skip to content

Commit a38c535

Browse files
sharpninjaCopilot
andcommitted
Accordion behavior: collapse sibling groups when expanding one
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 3210d84 commit a38c535

1 file changed

Lines changed: 17 additions & 1 deletion

File tree

src/RequestTracker.Core/ViewModels/MainWindowViewModel.cs

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,23 @@ private void TreeItemTapped(FileNode? node)
224224
return;
225225
}
226226
if (node.IsDirectory)
227-
node.IsExpanded = !node.IsExpanded;
227+
{
228+
bool expanding = !node.IsExpanded;
229+
node.IsExpanded = expanding;
230+
231+
// Accordion: collapse siblings when expanding a directory
232+
if (expanding)
233+
{
234+
foreach (var topNode in Nodes)
235+
{
236+
foreach (var sibling in topNode.Children)
237+
{
238+
if (sibling != node && sibling.IsDirectory)
239+
sibling.IsExpanded = false;
240+
}
241+
}
242+
}
243+
}
228244
SelectedNode = node;
229245
}
230246

0 commit comments

Comments
 (0)