Skip to content

Commit 97e1aba

Browse files
committed
Fix: Focus issue if profile filter is open
1 parent ef6c33f commit 97e1aba

File tree

5 files changed

+50
-10
lines changed

5 files changed

+50
-10
lines changed

Source/NETworkManager.Settings/ConfigurationInfo.cs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -451,6 +451,27 @@ public bool IsChildWindowOpen
451451
}
452452
}
453453

454+
/// <summary>
455+
/// Private variable for <see cref="IsProfileFilterPopupOpen" />.
456+
/// </summary>
457+
private bool _isProfileFilterPopupOpen;
458+
459+
/// <summary>
460+
/// Indicates if a profile filter popup is open.
461+
/// </summary>
462+
public bool IsProfileFilterPopupOpen
463+
{
464+
get => _isProfileFilterPopupOpen;
465+
set
466+
{
467+
if (value == _isProfileFilterPopupOpen)
468+
return;
469+
470+
_isProfileFilterPopupOpen = value;
471+
OnPropertyChanged();
472+
}
473+
}
474+
454475
/// <summary>
455476
/// Private variable for <see cref="FixAirspace" />.
456477
/// </summary>

Source/NETworkManager/MainWindow.xaml.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1443,7 +1443,7 @@ private async void LoadProfile(ProfileFileInfo info, bool showWrongPassword = fa
14431443
}, info.Name, showWrongPassword);
14441444

14451445
childWindow.Title = Strings.UnlockProfileFile;
1446-
1446+
14471447
childWindow.DataContext = viewModel;
14481448

14491449
ConfigurationManager.OnDialogOpen();
@@ -2004,10 +2004,16 @@ private async void FocusEmbeddedWindow()
20042004
- Settings are opened
20052005
- Profile file DropDown is opened
20062006
- Application search TextBox is opened
2007+
- Profile filter (tags) popup is opened
20072008
- Dialog over an embedded window is opened (FixAirspace)
20082009
*/
2009-
if (SelectedApplication == null || SettingsViewIsOpen || IsProfileFileDropDownOpened ||
2010+
if (SelectedApplication == null ||
2011+
// MainWindow
2012+
SettingsViewIsOpen ||
2013+
IsProfileFileDropDownOpened ||
20102014
TextBoxApplicationSearchIsFocused ||
2015+
// Global dialogs
2016+
ConfigurationManager.Current.IsProfileFilterPopupOpen ||
20112017
ConfigurationManager.Current.FixAirspace)
20122018
return;
20132019

Source/NETworkManager/ViewModels/PowerShellHostViewModel.cs

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -233,10 +233,10 @@ public bool IsProfileFilterSet
233233
OnPropertyChanged();
234234
}
235235
}
236-
236+
237237
private readonly GroupExpanderStateStore _groupExpanderStateStore = new();
238238
public GroupExpanderStateStore GroupExpanderStateStore => _groupExpanderStateStore;
239-
239+
240240
private bool _canProfileWidthChange = true;
241241
private double _tempProfileWidth;
242242

@@ -492,6 +492,8 @@ private void ClearSearchAction()
492492

493493
private void OpenProfileFilterAction()
494494
{
495+
ConfigurationManager.Current.IsProfileFilterPopupOpen = true;
496+
495497
ProfileFilterIsOpen = true;
496498
}
497499

@@ -517,7 +519,7 @@ private void ClearProfileFilterAction()
517519
IsProfileFilterSet = false;
518520
ProfileFilterIsOpen = false;
519521
}
520-
522+
521523
public ICommand ExpandAllProfileGroupsCommand => new RelayCommand(_ => ExpandAllProfileGroupsAction());
522524

523525
private void ExpandAllProfileGroupsAction()
@@ -531,7 +533,7 @@ private void CollapseAllProfileGroupsAction()
531533
{
532534
SetIsExpandedForAllProfileGroups(false);
533535
}
534-
536+
535537
public ICommand OpenSettingsCommand => new RelayCommand(_ => OpenSettingsAction());
536538

537539
private static void OpenSettingsAction()
@@ -674,7 +676,7 @@ private void SetIsExpandedForAllProfileGroups(bool isExpanded)
674676
foreach (var group in Profiles.Groups.Cast<CollectionViewGroup>())
675677
GroupExpanderStateStore[group.Name.ToString()] = isExpanded;
676678
}
677-
679+
678680
private void ResizeProfile(bool dueToChangedSize)
679681
{
680682
_canProfileWidthChange = false;
@@ -766,7 +768,7 @@ private void CreateTags()
766768
ProfileFilterTags.Add(new ProfileFilterTagsInfo(false, tag));
767769
}
768770
}
769-
771+
770772
private void SetProfilesView(ProfileFilterInfo filter, ProfileInfo profile = null)
771773
{
772774
Profiles = new CollectionViewSource
@@ -809,6 +811,11 @@ private void RefreshProfiles()
809811
}, SelectedProfile);
810812
}
811813

814+
public void OnProfileFilterClosed()
815+
{
816+
ConfigurationManager.Current.IsProfileFilterPopupOpen = false;
817+
}
818+
812819
public void OnProfileManagerDialogOpen()
813820
{
814821
ConfigurationManager.OnDialogOpen();
@@ -841,7 +848,7 @@ private void WriteDefaultProfileToRegistry()
841848
private void ProfileManager_OnProfilesUpdated(object sender, EventArgs e)
842849
{
843850
CreateTags();
844-
851+
845852
RefreshProfiles();
846853
}
847854

Source/NETworkManager/Views/PowerShellHostView.xaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -360,6 +360,7 @@
360360
</Button>
361361
<Popup PlacementTarget="{Binding ElementName=ButtonProfileFilter}"
362362
Placement="Bottom" StaysOpen="False"
363+
Closed="PopupProfileFilter_Closed"
363364
IsOpen="{Binding ProfileFilterIsOpen}"
364365
Width="220">
365366
<Border Background="{DynamicResource MahApps.Brushes.Window.Background}"

Source/NETworkManager/Views/PowerShellHostView.xaml.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,4 +61,9 @@ public void FocusEmbeddedWindow()
6161
{
6262
_viewModel.FocusEmbeddedWindow();
6363
}
64-
}
64+
65+
private void PopupProfileFilter_Closed(object sender, System.EventArgs e)
66+
{
67+
_viewModel.OnProfileFilterClosed();
68+
}
69+
}

0 commit comments

Comments
 (0)