Skip to content

Commit a999d09

Browse files
committed
ux: reset scroll offset after viewing commit changed
Signed-off-by: leo <[email protected]>
1 parent fbce29b commit a999d09

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

src/ViewModels/CommitDetail.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55
using System.Threading;
66
using System.Threading.Tasks;
77

8+
using Avalonia;
89
using Avalonia.Threading;
10+
911
using CommunityToolkit.Mvvm.ComponentModel;
1012

1113
namespace SourceGit.ViewModels
@@ -157,6 +159,12 @@ public bool CanOpenRevisionFileWithDefaultEditor
157159
private set => SetProperty(ref _canOpenRevisionFileWithDefaultEditor, value);
158160
}
159161

162+
public Vector ScrollOffset
163+
{
164+
get => _scrollOffset;
165+
set => SetProperty(ref _scrollOffset, value);
166+
}
167+
160168
public CommitDetail(Repository repo, CommitDetailSharedData sharedData)
161169
{
162170
_repo = repo;
@@ -355,6 +363,7 @@ private void Refresh()
355363
Children = null;
356364
RevisionFileSearchFilter = string.Empty;
357365
RevisionFileSearchSuggestion = null;
366+
ScrollOffset = Vector.Zero;
358367

359368
if (_commit == null)
360369
return;
@@ -640,5 +649,6 @@ private async Task SetViewingCommitAsync(Models.Object file)
640649
private string _revisionFileSearchFilter = string.Empty;
641650
private List<string> _revisionFileSearchSuggestion = null;
642651
private bool _canOpenRevisionFileWithDefaultEditor = false;
652+
private Vector _scrollOffset = Vector.Zero;
643653
}
644654
}

src/Views/CommitDetail.axaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
<TextBlock Classes="tab_header" Text="{DynamicResource Text.CommitDetail.Info}"/>
1717
</TabItem.Header>
1818

19-
<ScrollViewer HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Auto">
19+
<ScrollViewer Offset="{Binding ScrollOffset, Mode=TwoWay}" HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Auto">
2020
<StackPanel Orientation="Vertical">
2121
<!-- Base Information -->
2222
<v:CommitBaseInfo Content="{Binding Commit}"

0 commit comments

Comments
 (0)