Skip to content
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

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

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

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 Copilot bot 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

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
platform/macOS 🍏 macOS / Mac Catalyst t/a11y Relates to accessibility
Projects
Status: Changes Requested
2 participants