Skip to content

Comments

[A11y] Add SemanticProperties.Description to the Toolbar Icon#27119

Merged
tj-devel709 merged 7 commits intomainfrom
dev/TJ/A11y-toolbaricon
Jan 23, 2025
Merged

[A11y] Add SemanticProperties.Description to the Toolbar Icon#27119
tj-devel709 merged 7 commits intomainfrom
dev/TJ/A11y-toolbaricon

Conversation

@tj-devel709
Copy link
Member

Description of Change

In the this issue: #26816, our A11y folks pointed out that Toolbar.Items with IconImageSource set do not properly have a "Label" in the accessibility inspector on Mac. This is important because that label allows the VoiceControl and VoiceOver to work properly for that button.

In the examples below you can see the accessibility inspector on the right with the label set on the After and not the Before.

    <ContentPage.ToolbarItems>
        <ToolbarItem
            Command="{Binding GroceriesCommand}"
            Order="Primary"
            Priority="0"
            IconImageSource="groceries.png"
            SemanticProperties.Description="Groceries" />
    </ContentPage.ToolbarItems>

Before:

Screenshot 2025-01-14 at 11 13 46 AM

After:

Screenshot 2025-01-13 at 5 45 37 PM

Issues Fixed

Partially resolves: #26816

@tj-devel709 tj-devel709 added platform/macos macOS / Mac Catalyst t/a11y Relates to accessibility labels Jan 14, 2025
@tj-devel709 tj-devel709 added this to the .NET 9 SR4 milestone Jan 14, 2025
Copilot AI review requested due to automatic review settings January 14, 2025 17:24
@tj-devel709 tj-devel709 requested a review from a team as a code owner January 14, 2025 17:24
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot reviewed 1 out of 1 changed files in this pull request and generated no comments.

Comments suppressed due to low confidence (1)

src/Controls/src/Core/Compatibility/iOS/Extensions/AccessibilityExtensions.cs:90

  • Ensure that the new behavior introduced by SemanticProperties.GetDescription is covered by tests.
Control.AccessibilityLabel = SemanticProperties.GetDescription(Element) ?? (string)Element.GetValue(AutomationProperties.NameProperty) ?? _defaultAccessibilityLabel;

Copy link
Member

@PureWeen PureWeen left a comment

Choose a reason for hiding this comment

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

I'm thinking we should fix all of the methods in here to route the UpdateSemantics implementations.

		public static string SetAccessibilityLabel(this NativeView Control, Element Element, string _defaultAccessibilityLabel = null)
		{
			if (Element is IView view && view.Semantics != null)
			{
				Control.UpdateSemantics(view);
				return String.Empty;
			}

And then create an issue/comment to obsolete this code in NET10

@tj-devel709 tj-devel709 enabled auto-merge (squash) January 22, 2025 23:01
@tj-devel709 tj-devel709 merged commit bc47655 into main Jan 23, 2025
104 checks passed
@tj-devel709 tj-devel709 deleted the dev/TJ/A11y-toolbaricon branch January 23, 2025 18:55
@github-actions github-actions bot locked and limited conversation to collaborators Feb 23, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

platform/macos macOS / Mac Catalyst t/a11y Relates to accessibility

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

No name is provided for "checkboxes", "clear" and "New Task" button: A11y_.NET 9 template_.NET 9 template_Project_Name Role Value.

2 participants