Thanks to visit codestin.com
Credit goes to github.com

Skip to content
This repository was archived by the owner on May 1, 2024. It is now read-only.

Implement SetSemanticFocus and Announce APIs #1727

Merged
merged 9 commits into from
Dec 16, 2021

Conversation

rachelkang
Copy link
Collaborator

Description of Bug

Implements SetSemanticFocus and Announce APIs for screen reader accessibility

Future TODO: Implement Support SetSemanticFocus on Windows

Issues Fixed

Behavioral Changes

SetSemanticFocus can be leveraged to direct the screen reader focus to a specific control
Announce can be leveraged to instruct the screen reader to announce specific text

PR Checklist

  • Has a linked Issue, and the Issue has been approved
  • Has tests (if omitted, state reason in description)
  • Has samples (if omitted, state reason in description)
  • Rebased on top of main at time of PR
  • Changes adhere to coding standard

@rachelkang rachelkang added the a11y Issue/PR has to do with accessibility label Nov 19, 2021
AutomationNotificationKind.ActionAborted,
AutomationNotificationProcessing.ImportantMostRecent,
text,
"270FA098-C644-40A2-A0BE-A9BEA1222A1E");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you move it to constants with an appropriate name?

Copy link
Contributor

@pictos pictos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rachelkang Thanks for this❣️ can you take a look on my suggestion on for loop? I'll keep it as a comment to not block the merge (:

public static partial class SemanticExtensions
{
static void PlatformSetSemanticFocus(this VisualElement element) =>
throw new NotSupportedException($"The current platform '{Device.RuntimePlatform}' does not support Xamarin.CommunityToolkit.SemanticExtensions");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note for the future me. Create an exception helper class like essentials

// you really shouldn't be using the announce API
static AutomationPeer? FindAutomationPeer(DependencyObject depObj)
{
if (depObj != null)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we invert this if?

{
if (depObj != null)
{
for (var i = 0; i < VisualTreeHelper.GetChildrenCount(depObj); i++)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we cache the VisualTreeHelper.GetChildrenCount() value? (If it doesn't change)

@TheCodeTraveler TheCodeTraveler added this to the 1.4 milestone Nov 24, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
a11y Issue/PR has to do with accessibility
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Spec] Add SetSemanticFocus and Announce methods for accessibility
7 participants