fix(ui): default-expand diff tree; reliable row-click toggle

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
mika kuns
2026-05-19 11:50:36 +02:00
parent 232d7cb647
commit 7e3ae704fe
3 changed files with 8 additions and 3 deletions

View File

@@ -20,6 +20,7 @@ public sealed partial class WorktreeNodeViewModel : ViewModelBase
public bool IsDirectory { get; init; } public bool IsDirectory { get; init; }
public string RelativePath { get; init; } = ""; public string RelativePath { get; init; } = "";
public ObservableCollection<WorktreeNodeViewModel> Children { get; } = new(); public ObservableCollection<WorktreeNodeViewModel> Children { get; } = new();
[ObservableProperty] private bool _isExpanded = true;
} }
public sealed partial class WorktreeModalViewModel : ViewModelBase public sealed partial class WorktreeModalViewModel : ViewModelBase

View File

@@ -56,6 +56,11 @@
SelectedItem="{Binding SelectedNode, Mode=TwoWay}" SelectedItem="{Binding SelectedNode, Mode=TwoWay}"
Background="Transparent" Background="Transparent"
Margin="8,0,4,8"> Margin="8,0,4,8">
<TreeView.Styles>
<Style Selector="TreeViewItem" x:DataType="vm:WorktreeNodeViewModel">
<Setter Property="IsExpanded" Value="{Binding IsExpanded, Mode=TwoWay}"/>
</Style>
</TreeView.Styles>
<TreeView.ItemTemplate> <TreeView.ItemTemplate>
<TreeDataTemplate DataType="vm:WorktreeNodeViewModel" <TreeDataTemplate DataType="vm:WorktreeNodeViewModel"
ItemsSource="{Binding Children}"> ItemsSource="{Binding Children}">

View File

@@ -62,9 +62,8 @@ public partial class WorktreeModalView : Window
if (sender is not Control c) return; if (sender is not Control c) return;
if (c.DataContext is not WorktreeNodeViewModel node) return; if (c.DataContext is not WorktreeNodeViewModel node) return;
if (!node.IsDirectory) return; if (!node.IsDirectory) return;
var tvi = c.FindAncestorOfType<TreeViewItem>(); node.IsExpanded = !node.IsExpanded;
if (tvi is null) return; e.Handled = true;
tvi.IsExpanded = !tvi.IsExpanded;
} }
private void OnTitleBarPressed(object? sender, PointerPressedEventArgs e) private void OnTitleBarPressed(object? sender, PointerPressedEventArgs e)