-
Notifications
You must be signed in to change notification settings - Fork 8.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make SUI previews readable by screen readers #18418
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -15,6 +15,7 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation | |||||
DependencyProperty SettingContainer::_FontIconGlyphProperty{ nullptr }; | ||||||
DependencyProperty SettingContainer::_CurrentValueProperty{ nullptr }; | ||||||
DependencyProperty SettingContainer::_CurrentValueTemplateProperty{ nullptr }; | ||||||
DependencyProperty SettingContainer::_CurrentValueAccessibleNameProperty{ nullptr }; | ||||||
DependencyProperty SettingContainer::_HasSettingValueProperty{ nullptr }; | ||||||
DependencyProperty SettingContainer::_SettingOverrideSourceProperty{ nullptr }; | ||||||
DependencyProperty SettingContainer::_StartExpandedProperty{ nullptr }; | ||||||
|
@@ -63,7 +64,7 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation | |||||
L"CurrentValue", | ||||||
xaml_typename<IInspectable>(), | ||||||
xaml_typename<Editor::SettingContainer>(), | ||||||
PropertyMetadata{ nullptr }); | ||||||
PropertyMetadata{ nullptr, PropertyChangedCallback{ &SettingContainer::_OnCurrentValueChanged } }); | ||||||
} | ||||||
if (!_CurrentValueTemplateProperty) | ||||||
{ | ||||||
|
@@ -74,6 +75,15 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation | |||||
xaml_typename<Editor::SettingContainer>(), | ||||||
PropertyMetadata{ nullptr }); | ||||||
} | ||||||
if (!_CurrentValueAccessibleNameProperty) | ||||||
{ | ||||||
_CurrentValueAccessibleNameProperty = | ||||||
DependencyProperty::Register( | ||||||
L"CurrentValueAccessibleName", | ||||||
xaml_typename<Windows::UI::Xaml::DataTemplate>(), | ||||||
xaml_typename<Editor::SettingContainer>(), | ||||||
PropertyMetadata{ box_value(L""), PropertyChangedCallback{ &SettingContainer::_OnCurrentValueChanged } }); | ||||||
} | ||||||
if (!_HasSettingValueProperty) | ||||||
{ | ||||||
_HasSettingValueProperty = | ||||||
|
@@ -103,6 +113,12 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation | |||||
} | ||||||
} | ||||||
|
||||||
void SettingContainer::_OnCurrentValueChanged(const Windows::UI::Xaml::DependencyObject& d, const Windows::UI::Xaml::DependencyPropertyChangedEventArgs& /*e*/) | ||||||
{ | ||||||
const auto& obj{ d.try_as<Editor::SettingContainer>() }; | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
not necessary; decays to |
||||||
get_self<SettingContainer>(obj)->_UpdateCurrentValueAutoProp(); | ||||||
} | ||||||
|
||||||
void SettingContainer::_OnHasSettingValueChanged(const DependencyObject& d, const DependencyPropertyChangedEventArgs& /*args*/) | ||||||
{ | ||||||
// update visibility for override message and reset button | ||||||
|
@@ -174,14 +190,8 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation | |||||
|
||||||
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(obj, *headerText); | ||||||
} | ||||||
} | ||||||
// apply header and current value as name (automation property) | ||||||
Automation::AutomationProperties::SetName(obj, _GenerateAccessibleName()); | ||||||
|
||||||
// apply help text as tooltip and full description (automation property) | ||||||
if (const auto& helpText{ HelpText() }; !helpText.empty()) | ||||||
|
@@ -247,6 +257,17 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation | |||||
} | ||||||
} | ||||||
|
||||||
void SettingContainer::_UpdateCurrentValueAutoProp() | ||||||
{ | ||||||
if (const auto& child{ GetTemplateChild(L"Expander") }) | ||||||
{ | ||||||
if (const auto& expander{ child.try_as<Microsoft::UI::Xaml::Controls::Expander>() }) | ||||||
{ | ||||||
Automation::AutomationProperties::SetName(expander, _GenerateAccessibleName()); | ||||||
} | ||||||
} | ||||||
} | ||||||
|
||||||
// Method Description: | ||||||
// - Helper function for generating the override message | ||||||
// Arguments: | ||||||
|
@@ -279,4 +300,37 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation | |||||
} | ||||||
return RS_(L"SettingContainer_OverrideMessageBaseLayer"); | ||||||
} | ||||||
|
||||||
// Method Description: | ||||||
// - Helper function for generating the accessible name | ||||||
// Return Value: | ||||||
// - text specifying the accessible name. Includes header and current value, if available. | ||||||
hstring SettingContainer::_GenerateAccessibleName() | ||||||
{ | ||||||
hstring name{}; | ||||||
if (const auto& header{ Header() }) | ||||||
{ | ||||||
if (const auto headerText{ header.try_as<hstring>() }) | ||||||
{ | ||||||
name = *headerText; | ||||||
} | ||||||
|
||||||
// append current value to the name, if it exists | ||||||
if (const auto currentValAccessibleName{ CurrentValueAccessibleName() }; !currentValAccessibleName.empty()) | ||||||
{ | ||||||
// prefer CurrentValueAccessibleName, if it exists | ||||||
name = name + L": " + currentValAccessibleName; | ||||||
} | ||||||
else if (const auto& currentVal{ CurrentValue() }) | ||||||
{ | ||||||
// the accessible name was not defined, so try to | ||||||
// extract the value directly from the CurrentValue property | ||||||
if (const auto currentValText{ currentVal.try_as<hstring>() }) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i love this |
||||||
{ | ||||||
name = name + L": " + *currentValText; | ||||||
} | ||||||
} | ||||||
} | ||||||
return name; | ||||||
} | ||||||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
love this!