Repository: microsoft/terminal (language: cpp)

Issue:
[Settings - Startup]: Name is not defined for the button present under 'Startup' tab.
### Windows Terminal version

1.13.10984.0

### Windows build number

22598.200

### Other Software

**Test Environment:**
**OS:** Windows 11 Version 21H2 (OS Build 22598.200)
**Screen Reader:** Narrator

### Steps to reproduce

**Repro Steps:**
Open Windows Terminal.
Open Settings page using "Ctrl + ',' ".
Verify that Name is not defined for the button present under 'Startup' tab.

**User Experience: -> Priority 1**
User who relies on screen reader will be affected and not be able to know what the control is and what is its functionality if name is not defined for the control.

**Guideline Reference:**
https://www.w3.org/WAI/WCAG21/Understanding/name-role-value.html

**Attachments:**
[Name is not defined for the button present under 'Startup' tab..zip](https://github.com/microsoft/terminal/files/8602787/Name.is.not.defined.for.the.button.present.under.Startup.tab.zip)



### Expected Behavior

Name should be defined for the button present under 'Startup' tab.
Screen reader should announce "When terminal starts button collapse/expand button".

### Actual Behavior

Name is not defined for the button present under 'Startup' tab.
Screen reader announces, "group collapse".


Discussion / hints:
Hey look, @carlos-zamora was right, this one would get picked up.

Previous thread: #12317



Fix patch:
diff --git a/src/cascadia/TerminalSettingsEditor/SettingContainer.cpp b/src/cascadia/TerminalSettingsEditor/SettingContainer.cpp
index 2fa0d14f25b..11ee518458a 100644
--- a/src/cascadia/TerminalSettingsEditor/SettingContainer.cpp
+++ b/src/cascadia/TerminalSettingsEditor/SettingContainer.cpp
@@ -122,28 +122,40 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
 
         _UpdateOverrideSystem();
 
-        if (const auto& content{ Content() })
+        // Get the correct base to apply automation properties to
+        DependencyObject base{ nullptr };
+        if (const auto& child{ GetTemplateChild(L"Expander") })
+        {
+            if (const auto& expander{ child.try_as<Microsoft::UI::Xaml::Controls::Expander>() })
+            {
+                base = child;
+            }
+        }
+        else if (const auto& content{ Content() })
         {
             if (const auto& obj{ content.try_as<DependencyObject>() })
             {
-                // apply header text as name (automation property)
-                if (const auto& header{ Header() })
-                {
-                    const auto headerText{ header.try_as<hstring>() };
-                    if (headerText && !headerText->empty())
-                    {
-                        Automation::AutomationProperties::SetName(obj, *headerText);
-                    }
-                }
+                base = obj;
+            }
+        }
 
-                // apply help text as tooltip and full description (automation property)
-                const auto& helpText{ HelpText() };
-                if (!helpText.empty())
+        if (base)
+        {
+            // apply header as name (automation property)
+            if (const auto& header{ Header() })
+            {
+                if (const auto headerText{ header.try_as<hstring>() })
                 {
-                    Controls::ToolTipService::SetToolTip(obj, box_value(helpText));
-                    Automation::AutomationProperties::SetFullDescription(obj, helpText);
+                    Automation::AutomationProperties::SetName(base, *headerText);
                 }
             }
+
+            // apply help text as tooltip and full description (automation property)
+            if (const auto& helpText{ HelpText() }; !helpText.empty())
+            {
+                Controls::ToolTipService::SetToolTip(base, box_value(helpText));
+                Automation::AutomationProperties::SetFullDescription(base, helpText);
+            }
         }
 
         if (HelpText().empty())
diff --git a/src/cascadia/TerminalSettingsEditor/SettingContainerStyle.xaml b/src/cascadia/TerminalSettingsEditor/SettingContainerStyle.xaml
index 5efb9a2ebb6..6552bc19872 100644
--- a/src/cascadia/TerminalSettingsEditor/SettingContainerStyle.xaml
+++ b/src/cascadia/TerminalSettingsEditor/SettingContainerStyle.xaml
@@ -142,7 +142,8 @@
         <Setter Property="Template">
             <Setter.Value>
                 <ControlTemplate TargetType="local:SettingContainer">
-                    <muxc:Expander Margin="0,4,0,0"
+                    <muxc:Expander x:Name="Expander"
+                                   Margin="0,4,0,0"
                                    HorizontalAlignment="Stretch"
                                    HorizontalContentAlignment="Stretch"
                                    Content="{TemplateBinding Content}">


Test patch: