Skip to content

Commit

Permalink
Apply AutoProps to TextBox settings in SUI (#14178)
Browse files Browse the repository at this point in the history
We already were setting the automation properties on the expander, however, we were not setting it on the content when an expander was present. This change applies the automation properties to both the expander and the child content (i.e. TextBox).

Closes #13827

(cherry picked from commit 62b34cf)
Service-Card-Id: 87207143
Service-Version: 1.15
  • Loading branch information
carlos-zamora authored and DHowett committed Dec 12, 2022
1 parent 28e6265 commit 0f1ce90
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions src/cascadia/TerminalSettingsEditor/SettingContainer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,37 +123,40 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
_UpdateOverrideSystem();

// Get the correct base to apply automation properties to
DependencyObject base{ nullptr };
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 = child;
base.push_back(child);
}
}
else if (const auto& content{ Content() })
if (const auto& content{ Content() })
{
if (const auto& obj{ content.try_as<DependencyObject>() })
const auto& panel{ content.try_as<Controls::Panel>() };
const auto& obj{ content.try_as<DependencyObject>() };
if (!panel && obj)
{
base = obj;
base.push_back(obj);
}
}

if (base)
for (const auto& obj : base)
{
// apply header as name (automation property)
if (const auto& header{ Header() })
{
if (const auto headerText{ header.try_as<hstring>() })
{
Automation::AutomationProperties::SetName(base, *headerText);
Automation::AutomationProperties::SetName(obj, *headerText);
}
}

// apply help text as tooltip and full description (automation property)
if (const auto& helpText{ HelpText() }; !helpText.empty())
{
Automation::AutomationProperties::SetFullDescription(base, helpText);
Automation::AutomationProperties::SetFullDescription(obj, helpText);
}
}

Expand Down

0 comments on commit 0f1ce90

Please sign in to comment.