Repository: microsoft/terminal
File: src/cascadia/TerminalSettingsEditor/SettingContainer.cpp (C++)

Code before:
                            return;
                        }
                        else if (const auto& panel{ content.try_as<Controls::Panel>() })
                        {
                            for (const auto& panelChild : panel.Children())
                            {
                                if (const auto& panelControl{ panelChild.try_as<Controls::Control>() })
                                {
                                    panelControl.Focus(FocusState::Programmatic);
                                    return;
                                }
                            }
                        }
                        // if we get here, we didn't find something to reasonably focus to.
                    }
                });

                // apply name (automation property)
                Automation::AutomationProperties::SetName(child, RS_(L"SettingContainer_OverrideMessageBaseLayer"));
            }
        }

        _UpdateOverrideSystem();

        // Get the correct base to apply automation properties to
        std::vector<DependencyObject> base(2, nullptr);
        if (const auto& child{ GetTemplateChild(L"Expander") })
        {
            if (const auto& expander{ child.try_as<Microsoft::UI::Xaml::Controls::Expander>() })
            {
                base.push_back(child);
            }
        }
        if (const auto& content{ Content() })
        {
            if (const auto& obj{ content.try_as<DependencyObject>() })
            {
                base.push_back(obj);
            }
        }

        for (auto obj : base)
        {
            if (obj)
            {
                // apply header as name (automation property)
                if (const auto& header{ Header() })
                {
                    if (const auto headerText{ header.try_as<hstring>() })
                    {
                        Automation::AutomationProperties::SetName(obj, *headerText);

Review comment (bug):
wait, doesn't this create a vector with `nullptr, nullptr` and then you add two _new_ elements to it (`nullptr, nullptr, expander, content`)?

Recommend .. not doing that. I saw the nullptr check down on R154 and it made me realize something was amiss. You're never adding a nullptr, so why check?

Code after:
                            return;
                        }
                        else if (const auto& panel{ content.try_as<Controls::Panel>() })
                        {
                            for (const auto& panelChild : panel.Children())
                            {
                                if (const auto& panelControl{ panelChild.try_as<Controls::Control>() })
                                {
                                    panelControl.Focus(FocusState::Programmatic);
                                    return;
                                }
                            }
                        }
                        // if we get here, we didn't find something to reasonably focus to.
                    }
                });

                // apply name (automation property)
                Automation::AutomationProperties::SetName(child, RS_(L"SettingContainer_OverrideMessageBaseLayer"));
            }
        }

        _UpdateOverrideSystem();

        // Get the correct base to apply automation properties to
        std::vector<DependencyObject> base;
        base.reserve(2);
        if (const auto& child{ GetTemplateChild(L"Expander") })
        {
            if (const auto& expander{ child.try_as<Microsoft::UI::Xaml::Controls::Expander>() })
            {
                base.push_back(child);
            }
        }
        if (const auto& content{ Content() })
        {
            const auto& panel{ content.try_as<Controls::Panel>() };
            const auto& obj{ content.try_as<DependencyObject>() };
            if (!panel && obj)
            {
                base.push_back(obj);
            }
        }

        for (const auto& obj : base)
        {
            // apply header as name (automation property)
            if (const auto& header{ Header() })
            {
                if (const auto headerText{ header.try_as<hstring>() })
                {