Skip to content

Commit b9ce510

Browse files
committed
fix: hide suggestion box when the parent TextBox is invisible (#2662)
Signed-off-by: leo <longshuang@msn.cn>
1 parent 426e445 commit b9ce510

3 files changed

Lines changed: 14 additions & 3 deletions

File tree

src/Views/CommitMessageToolBox.axaml.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,7 @@ protected override void OnKeyDown(KeyEventArgs e)
379379

380380
private void OnLayoutUpdated(object sender, EventArgs e)
381381
{
382-
if (_textPresenter == null)
382+
if (_textPresenter == null || !IsEffectivelyVisible)
383383
{
384384
SubjectEndY = 0;
385385
SuggestionPopupY = 0;

src/Views/RevisionFiles.axaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@
2828
Watermark="{DynamicResource Text.CommitDetail.Files.Search}"
2929
Text="{Binding RevisionFileSearchFilter, Mode=TwoWay}"
3030
KeyDown="OnSearchBoxKeyDown"
31-
TextChanged="OnSearchBoxTextChanged">
31+
TextChanged="OnSearchBoxTextChanged"
32+
LayoutUpdated="OnSearchBoxLayoutUpdated">
3233
<TextBox.InnerLeftContent>
3334
<Path Width="14" Height="14" Margin="4,0,0,0" Fill="{DynamicResource Brush.FG2}" Data="{StaticResource Icons.Search}"/>
3435
</TextBox.InnerLeftContent>

src/Views/RevisionFiles.axaml.cs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
using System;
12
using Avalonia.Controls;
23
using Avalonia.Input;
34
using Avalonia.Interactivity;
@@ -31,7 +32,7 @@ private async void OnSearchBoxKeyDown(object _, KeyEventArgs e)
3132
{
3233
if (vm.RevisionFileSearchSuggestion?.Count > 0)
3334
{
34-
SearchSuggestionBox.Focus(NavigationMethod.Tab);
35+
SearchSuggestionBox.Focus(NavigationMethod.Directional);
3536
SearchSuggestionBox.SelectedIndex = 0;
3637
}
3738

@@ -50,6 +51,15 @@ private async void OnSearchBoxTextChanged(object _, TextChangedEventArgs e)
5051
await FileTree.SetSearchResultAsync(null);
5152
}
5253

54+
private void OnSearchBoxLayoutUpdated(object sender, EventArgs e)
55+
{
56+
if (DataContext is not ViewModels.CommitDetail vm)
57+
return;
58+
59+
if (sender is TextBox { IsEffectivelyVisible: false })
60+
vm.CancelRevisionFileSuggestions();
61+
}
62+
5363
private async void OnSearchSuggestionBoxKeyDown(object _, KeyEventArgs e)
5464
{
5565
if (DataContext is not ViewModels.CommitDetail vm)

0 commit comments

Comments
 (0)