ux: reset scroll offset after viewing commit changed

Signed-off-by: leo <longshuang@msn.cn>
This commit is contained in:
leo
2025-12-11 14:35:28 +08:00
parent fbce29b9c3
commit a999d09c76
2 changed files with 11 additions and 1 deletions

View File

@@ -5,7 +5,9 @@ using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Tasks;
using Avalonia;
using Avalonia.Threading;
using CommunityToolkit.Mvvm.ComponentModel;
namespace SourceGit.ViewModels
@@ -157,6 +159,12 @@ namespace SourceGit.ViewModels
private set => SetProperty(ref _canOpenRevisionFileWithDefaultEditor, value);
}
public Vector ScrollOffset
{
get => _scrollOffset;
set => SetProperty(ref _scrollOffset, value);
}
public CommitDetail(Repository repo, CommitDetailSharedData sharedData)
{
_repo = repo;
@@ -355,6 +363,7 @@ namespace SourceGit.ViewModels
Children = null;
RevisionFileSearchFilter = string.Empty;
RevisionFileSearchSuggestion = null;
ScrollOffset = Vector.Zero;
if (_commit == null)
return;
@@ -640,5 +649,6 @@ namespace SourceGit.ViewModels
private string _revisionFileSearchFilter = string.Empty;
private List<string> _revisionFileSearchSuggestion = null;
private bool _canOpenRevisionFileWithDefaultEditor = false;
private Vector _scrollOffset = Vector.Zero;
}
}

View File

@@ -16,7 +16,7 @@
<TextBlock Classes="tab_header" Text="{DynamicResource Text.CommitDetail.Info}"/>
</TabItem.Header>
<ScrollViewer HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Auto">
<ScrollViewer Offset="{Binding ScrollOffset, Mode=TwoWay}" HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Auto">
<StackPanel Orientation="Vertical">
<!-- Base Information -->
<v:CommitBaseInfo Content="{Binding Commit}"