dotnet / maui

.NET MAUI is the .NET Multi-platform App UI, a framework for building native device applications spanning mobile, tablet, and desktop.
https://dot.net/maui
MIT License
21.95k stars 1.7k forks source link

MAUI should expose x:Name as AutomationId to accessibility tools (like VS accessibility checker) #12913

Open spadapet opened 1 year ago

spadapet commented 1 year ago

Description

Use Visual Studio (Windows) 17.5 preview. With a WinUI (or WPF app), controls with an x:Name have that name exposed as Automation ID to automation tools, such as accessibility tools and checkers.

Here's a WinUI example: image

With MAUI, only the AutomationId property is exposed as Automation ID, not x:Name. Example: image

To help the user and tools (like VS accessiblity checker) find the correct XAML element for automation elements, x:Name should be exposed as Automation ID in the same way that WPF and WinUI do it.

Steps to Reproduce

  1. Use Visual Studio 17.5 or newer
  2. Create a new blank MAUI app from template
  3. Replace the MainPage.xaml contents with:
    <Button x:Name="Button1" Text="Button" />
    <Button AutomationId="Button2" Text="Button" />
  1. F5 to build and debug app

  2. Click "Go to live visual tree" button in the in-app toolbar:

    image

  3. Click the accessibility checker button in the LVT tool window:

    image

  4. Notice the accessibility checker window shows the Automation ID for Button2 but not Button1 that was specified with x:Name:

    image

NOTE: If you do the same for an WPF or WinUI app, the x:Name does show up in the accessibility checker's Automation ID column.

Link to public reproduction project repository

n/a

Version with bug

7.0 (current)

Last version that worked well

Unknown/Other

Affected platforms

Windows

Affected platform versions

net7.0-windows10.0.19041.0

Did you find any workaround?

A workaround is to always set AutomationId on any element that also has an x:Name

Relevant log output

No response

PureWeen commented 1 year ago

Based on our conversations can we close this issue @spadapet ?

ghost commented 1 year ago

Hi @spadapet. We have added the "s/needs-info" label to this issue, which indicates that we have an open question for you before we can take further action. This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time.

ghost commented 1 year ago

This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment. If it is closed, feel free to comment when you are able to provide the additional information and we will re-investigate.

spadapet commented 1 year ago

@PureWeen sorry missed the comments earlier. Based on our conversation in Teams, this seems like a reasonable solution with x:Name:

With that, the x:Name would show up automatically in the Accessibility Checker tool window in VSWin. The column name will probably change though. Also x:Name would then work just like the other XAML platforms.

ghost commented 1 year ago

We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process.

jinxinjuan commented 1 year ago

Verified this issue with Visual Studio Enterprise 17.7.0 Preview 2.0. Can repro on windows platform with sample code.