|
15 | 15 | #include "GlobalAppearance.h" |
16 | 16 | #include "GlobalAppearanceViewModel.h" |
17 | 17 | #include "ColorSchemes.h" |
| 18 | +#include "EditColorScheme.h" |
18 | 19 | #include "AddProfile.h" |
19 | 20 | #include "InteractionViewModel.h" |
20 | 21 | #include "LaunchViewModel.h" |
@@ -293,16 +294,21 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation |
293 | 294 | const auto settingName{ args.PropertyName() }; |
294 | 295 | if (settingName == L"CurrentPage") |
295 | 296 | { |
| 297 | + // extract ElementToFocus and clear it; we only want to use it once |
| 298 | + auto vmImpl = get_self<ColorSchemesPageViewModel>(_colorSchemesPageVM); |
| 299 | + const auto elementToFocus = vmImpl->ElementToFocus(); |
| 300 | + vmImpl->ElementToFocus(L""); |
| 301 | + |
296 | 302 | const auto currentScheme = _colorSchemesPageVM.CurrentScheme(); |
297 | 303 | if (_colorSchemesPageVM.CurrentPage() == ColorSchemesSubPage::EditColorScheme && currentScheme) |
298 | 304 | { |
299 | | - contentFrame().Navigate(xaml_typename<Editor::EditColorScheme>(), currentScheme); |
| 305 | + contentFrame().Navigate(xaml_typename<Editor::EditColorScheme>(), winrt::make<NavigateToEditColorSchemeArgs>(currentScheme, elementToFocus)); |
300 | 306 | const auto crumb = winrt::make<Breadcrumb>(box_value(colorSchemesTag), currentScheme.Name(), BreadcrumbSubPage::ColorSchemes_Edit); |
301 | 307 | _breadcrumbs.Append(crumb); |
302 | 308 | } |
303 | 309 | else if (_colorSchemesPageVM.CurrentPage() == ColorSchemesSubPage::Base) |
304 | 310 | { |
305 | | - _Navigate(winrt::hstring{ colorSchemesTag }, BreadcrumbSubPage::None); |
| 311 | + _Navigate(winrt::hstring{ colorSchemesTag }, BreadcrumbSubPage::None, elementToFocus); |
306 | 312 | } |
307 | 313 | } |
308 | 314 | else if (settingName == L"CurrentSchemeName") |
@@ -862,16 +868,17 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation |
862 | 868 | { |
863 | 869 | _PreNavigateHelper(); |
864 | 870 |
|
865 | | - // TODO CARLOS: |
866 | | - // - should navigate to EditColorScheme, not ColorSchemes |
867 | | - // - EditColorScheme::OnNavigatedTo needs to accept NavigateToColorSchemesArgs (or similar) |
868 | | - // - EditColorScheme::OnNavigatedTo needs BringIntoViewWhenLoaded(args.ElementToFocus()) |
869 | 871 | const auto crumb = winrt::make<Breadcrumb>(box_value(colorSchemesTag), RS_(L"Nav_ColorSchemes/Content"), BreadcrumbSubPage::None); |
870 | 872 | _breadcrumbs.Append(crumb); |
871 | 873 | contentFrame().Navigate(xaml_typename<Editor::ColorSchemes>(), winrt::make<NavigateToColorSchemesArgs>(_colorSchemesPageVM, elementToFocus)); |
872 | 874 | SettingsNav().SelectedItem(ColorSchemesNavItem()); |
873 | 875 |
|
| 876 | + // Pass along the element to focus to the ColorSchemesPageViewModel. |
| 877 | + // This will work as a staging area before we navigate to EditColorScheme |
| 878 | + get_self<ColorSchemesPageViewModel>(_colorSchemesPageVM)->ElementToFocus(elementToFocus); |
| 879 | + |
874 | 880 | // Set CurrentScheme BEFORE the CurrentPage! |
| 881 | + // Doing so triggers the PropertyChanged event which performs the navigation to EditColorScheme |
875 | 882 | if (subPage == BreadcrumbSubPage::None) |
876 | 883 | { |
877 | 884 | _colorSchemesPageVM.CurrentScheme(nullptr); |
|
0 commit comments