Repository: microsoft/terminal (language: cpp)

Issue:
[Settings]: In scan mode, Screen Reader users are not able to open 'Open JSON file' control.
### Windows Terminal version

1.12.3472.0

### Windows build number

10.0.22504.1010

### Other Software

**Test Environment:**
OS: Windows 11 Version Dev (OS Build 22504.1010)
App: Windows Terminal Preview
Screen Reader: Narrator
Tool: Accessibility Insights for Windows Version 1.1.1741.1

### Steps to reproduce

**Repro Steps:**
1. Open Windows Terminal.
2. Open Settings page using 'Ctr+,'.
3. Open Narrator using 'Win+Ctrl+ Enter' key. Turn ON Narrator scan mode using 'Caps lock + Space' key.
4. Now navigate to 'Open JSON file' control and try to activate it then observe the issue.

**User Experience:**
Screen Reader users will be impacted here as they are not able to activate a control in scan mode which will not enhance the UX of those users.

**Guideline Reference:**
EN 301 549 V3.2.1: 11.5.2.12 Execution of available actions

**Attachments:**
[Uploading In scan mode, Screen Reader users are not able to open 'Open JSON file' control..zip…]()

### Expected Behavior

In scan mode, Screen Reader users should be able to open 'Open JSON file' control using 'Enter' key.

### Actual Behavior

In scan mode, Screen Reader users are not able to open 'Open JSON file' control using 'Enter' key. Screen Reader Users is only able to open JSON file in Scan off mode.


Discussion / hints:
Copying over some relevant information from #12319:
> > PowerToys v0.55 settings has a NavigationView. It doesn't have this issue.
XAML Controls Gallery also doesn't have this issue.

> Hmm. That might actually be on us then. PT Settings is also XAML Islands IIRC, so if their NavView works, then it's probably how we're using it.

There's a chance this is on https://github.com/microsoft/microsoft-ui-xaml, but we need to verify that first.

Fix patch:
diff --git a/src/cascadia/TerminalSettingsEditor/MainPage.cpp b/src/cascadia/TerminalSettingsEditor/MainPage.cpp
index 5daf396b72e..054c8480ccf 100644
--- a/src/cascadia/TerminalSettingsEditor/MainPage.cpp
+++ b/src/cascadia/TerminalSettingsEditor/MainPage.cpp
@@ -38,6 +38,7 @@ using namespace winrt::Windows::System;
 using namespace winrt::Windows::UI::Xaml::Controls;
 using namespace winrt::Windows::Foundation::Collections;
 
+static const std::wstring_view openJsonTag{ L"OpenJson_Nav" };
 static const std::wstring_view launchTag{ L"Launch_Nav" };
 static const std::wstring_view interactionTag{ L"Interaction_Nav" };
 static const std::wstring_view renderingTag{ L"Rendering_Nav" };
@@ -324,6 +325,17 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
 
             if (const auto navString = clickedItemContainer.Tag().try_as<hstring>())
             {
+                if (*navString == openJsonTag)
+                {
+                    const auto window = CoreWindow::GetForCurrentThread();
+                    const auto rAltState = window.GetKeyState(VirtualKey::RightMenu);
+                    const auto lAltState = window.GetKeyState(VirtualKey::LeftMenu);
+                    const auto altPressed = WI_IsFlagSet(lAltState, CoreVirtualKeyStates::Down) ||
+                                            WI_IsFlagSet(rAltState, CoreVirtualKeyStates::Down);
+                    const auto target = altPressed ? SettingsTarget::DefaultsFile : SettingsTarget::SettingsFile;
+                    OpenJson.raise(nullptr, target);
+                    return;
+                }
                 _Navigate(*navString, BreadcrumbSubPage::None);
             }
             else if (const auto profile = clickedItemContainer.Tag().try_as<Editor::ProfileViewModel>())
@@ -575,27 +587,6 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
         }
     }
 
-    void MainPage::OpenJsonTapped(const IInspectable& /*sender*/, const Windows::UI::Xaml::Input::TappedRoutedEventArgs& /*args*/)
-    {
-        const auto window = CoreWindow::GetForCurrentThread();
-        const auto rAltState = window.GetKeyState(VirtualKey::RightMenu);
-        const auto lAltState = window.GetKeyState(VirtualKey::LeftMenu);
-        const auto altPressed = WI_IsFlagSet(lAltState, CoreVirtualKeyStates::Down) ||
-                                WI_IsFlagSet(rAltState, CoreVirtualKeyStates::Down);
-
-        const auto target = altPressed ? SettingsTarget::DefaultsFile : SettingsTarget::SettingsFile;
-        OpenJson.raise(nullptr, target);
-    }
-
-    void MainPage::OpenJsonKeyDown(const IInspectable& /*sender*/, const Windows::UI::Xaml::Input::KeyRoutedEventArgs& args)
-    {
-        if (args.Key() == VirtualKey::Enter || args.Key() == VirtualKey::Space)
-        {
-            const auto target = args.KeyStatus().IsMenuKeyDown ? SettingsTarget::DefaultsFile : SettingsTarget::SettingsFile;
-            OpenJson.raise(nullptr, target);
-        }
-    }
-
     void MainPage::SaveButton_Click(const IInspectable& /*sender*/, const RoutedEventArgs& /*args*/)
     {
         _settingsClone.LogSettingChanges(false);
diff --git a/src/cascadia/TerminalSettingsEditor/MainPage.h b/src/cascadia/TerminalSettingsEditor/MainPage.h
index 81724effb11..582f8813b1d 100644
--- a/src/cascadia/TerminalSettingsEditor/MainPage.h
+++ b/src/cascadia/TerminalSettingsEditor/MainPage.h
@@ -30,8 +30,6 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
 
         void UpdateSettings(const Model::CascadiaSettings& settings);
 
-        void OpenJsonKeyDown(const Windows::Foundation::IInspectable& sender, const Windows::UI::Xaml::Input::KeyRoutedEventArgs& args);
-        void OpenJsonTapped(const Windows::Foundation::IInspectable& sender, const Windows::UI::Xaml::Input::TappedRoutedEventArgs& args);
         void SettingsNav_Loaded(const Windows::Foundation::IInspectable& sender, const Windows::UI::Xaml::RoutedEventArgs& args);
         void SettingsNav_ItemInvoked(const Microsoft::UI::Xaml::Controls::NavigationView& sender, const Microsoft::UI::Xaml::Controls::NavigationViewItemInvokedEventArgs& args);
         void SaveButton_Click(const Windows::Foundation::IInspectable& sender, const Windows::UI::Xaml::RoutedEventArgs& args);
diff --git a/src/cascadia/TerminalSettingsEditor/MainPage.xaml b/src/cascadia/TerminalSettingsEditor/MainPage.xaml
index 3a0773062aa..c6d36e8f200 100644
--- a/src/cascadia/TerminalSettingsEditor/MainPage.xaml
+++ b/src/cascadia/TerminalSettingsEditor/MainPage.xaml
@@ -171,8 +171,8 @@
             <!--  The OpenJson item needs both Tapped and KeyDown handler  -->
             <muxc:NavigationViewItem x:Name="OpenJsonNavItem"
                                      x:Uid="Nav_OpenJSON"
-                                     KeyDown="OpenJsonKeyDown"
-                                     Tapped="OpenJsonTapped">
+                                     SelectsOnInvoked="False"
+                                     Tag="OpenJson_Nav">
                 <muxc:NavigationViewItem.Icon>
                     <FontIcon Glyph="&#xE713;" />
                 </muxc:NavigationViewItem.Icon>


Test patch: