Skip to content

Commit

Permalink
Add automation properties to expander-style settings (#13032)
Browse files Browse the repository at this point in the history
## Summary of the Pull Request
Make sure we set `Name` and `FullDescription` on expander-style settings in the SUI

## PR Checklist
* [x] Closes #13019
* [x] CLA signed. If not, go over [here](https://cla.opensource.microsoft.com/microsoft/Terminal) and sign the CLA
* [ ] Tests added/passed
* [ ] Documentation updated. If checked, please file a pull request on [our docs repo](https://github.com/MicrosoftDocs/terminal) and link it here: #xxx
* [ ] Schema updated.
* [x] I work here

## Validation Steps Performed
Accessibility insights now shows the name/full description for the expander-style settings

(cherry picked from commit 71cbdc8)
Service-Card-Id: 81446420
Service-Version: 1.13
  • Loading branch information
PankajBhojwani authored and carlos-zamora committed May 12, 2022
1 parent ef4c02b commit 7f1c78e
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 16 deletions.
42 changes: 27 additions & 15 deletions src/cascadia/TerminalSettingsEditor/SettingContainer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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}">
Expand Down

0 comments on commit 7f1c78e

Please sign in to comment.