Skip to content

Commit

Permalink
Merge pull request #3088 from Jack251970/dev2
Browse files Browse the repository at this point in the history
Fix possible content frame navigation issue in welcome window & setting window
  • Loading branch information
jjw24 authored Nov 25, 2024
2 parents 9e46d3a + 929e7d6 commit db5b773
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 4 deletions.
1 change: 1 addition & 0 deletions Flow.Launcher/SettingWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@
IsPaneToggleButtonVisible="False"
IsSettingsVisible="False"
IsTabStop="False"
Loaded="NavView_Loaded"
OpenPaneLength="240"
PaneDisplayMode="Left"
SelectionChanged="NavigationView_SelectionChanged">
Expand Down
24 changes: 22 additions & 2 deletions Flow.Launcher/SettingWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ public SettingWindow(IPublicAPI api, SettingWindowViewModel viewModel)
_api = api;
InitializePosition();
InitializeComponent();
NavView.SelectedItem = NavView.MenuItems[0]; /* Set First Page */
}

private void OnLoaded(object sender, RoutedEventArgs e)
Expand Down Expand Up @@ -169,7 +168,11 @@ private void NavigationView_SelectionChanged(NavigationView sender, NavigationVi
else
{
var selectedItem = (NavigationViewItem)args.SelectedItem;
if (selectedItem == null) return;
if (selectedItem == null)
{
NavView_Loaded(sender, null); /* Reset First Page */
return;
}

var pageType = selectedItem.Name switch
{
Expand All @@ -186,5 +189,22 @@ private void NavigationView_SelectionChanged(NavigationView sender, NavigationVi
}
}

private void NavView_Loaded(object sender, RoutedEventArgs e)
{
if (ContentFrame.IsLoaded)
{
ContentFrame_Loaded(sender, e);
}
else
{
ContentFrame.Loaded += ContentFrame_Loaded;
}
}

private void ContentFrame_Loaded(object sender, RoutedEventArgs e)
{
NavView.SelectedItem ??= NavView.MenuItems[0]; /* Set First Page */
}

public record PaneData(Settings Settings, Updater Updater, IPortable Portable);
}
1 change: 1 addition & 0 deletions Flow.Launcher/WelcomeWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@
<ui:Frame
x:Name="ContentFrame"
HorizontalAlignment="Stretch"
Loaded="ContentFrame_Loaded"
ScrollViewer.CanContentScroll="True"
ScrollViewer.HorizontalScrollBarVisibility="Visible"
ScrollViewer.VerticalScrollBarVisibility="Visible">
Expand Down
9 changes: 7 additions & 2 deletions Flow.Launcher/WelcomeWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ public WelcomeWindow(Settings settings)
InitializeComponent();
BackButton.IsEnabled = false;
this.settings = settings;
ContentFrame.Navigate(PageTypeSelector(1), settings);
}

private NavigationTransitionInfo _transitionInfo = new SlideNavigationTransitionInfo()
Expand Down Expand Up @@ -102,9 +101,15 @@ private static Type PageTypeSelector(int pageNumber)
var tRequest = new TraversalRequest(FocusNavigationDirection.Next);
textBox.MoveFocus(tRequest);
}

private void OnActivated(object sender, EventArgs e)
{
Keyboard.ClearFocus();
}

private void ContentFrame_Loaded(object sender, RoutedEventArgs e)
{
ContentFrame.Navigate(PageTypeSelector(1), settings); /* Set First Page */
}
}
}
}

0 comments on commit db5b773

Please sign in to comment.