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

Fabric Text components do not provide their text value (Name) to accessibility tree #12030

Closed
chrisglein opened this issue Aug 16, 2023 · 1 comment · Fixed by #12039
Closed
Assignees
Labels
Area: Accessibility Area: Fabric Support Facebook Fabric Area: Text bug New Architecture Broad category for issues that apply to the RN "new" architecture of Turbo Modules + Fabric
Milestone

Comments

@chrisglein
Copy link
Member

Problem Description

See that the Name property is not set for a Text component:
image

Not sure if this is part of incomplete work already tracked here: #11898

Relevant code as far as I can tell is here:

case UIA_NamePropertyId: {
pRetVal->vt = VT_BSTR;
auto wideName = ::Microsoft::Common::Unicode::Utf8ToUtf16(props->accessibilityLabel);
pRetVal->bstrVal = SysAllocString(wideName.c_str());
hr = pRetVal->bstrVal != nullptr ? S_OK : E_OUTOFMEMORY;

Steps To Reproduce

See chrisglein/artificial-chat#119 (comment)

Expected Results

Accessibility Name should default to the text value

CLI version

12.0.0-alpha.6

Environment

info Fetching system and libraries information...
System:
  OS: Windows 10 10.0.23528
  CPU: "(24) x64 AMD Ryzen Threadripper PRO 3945WX 12-Cores     "
  Memory: 37.38 GB / 63.86 GB
Binaries:
  Node:
    version: 18.17.1
    path: C:\Program Files\nodejs\node.EXE
  Yarn:
    version: 1.22.19
    path: C:\Program Files (x86)\Yarn\bin\yarn.CMD
  npm:
    version: 9.4.1
    path: C:\Program Files\nodejs\npm.CMD
  Watchman: Not Found
SDKs:
  Android SDK: Not Found
  Windows SDK:
    AllowDevelopmentWithoutDevLicense: Enabled
    AllowAllTrustedApps: Enabled
    Versions:
      - 10.0.18362.0
      - 10.0.19041.0
      - 10.0.22000.0
      - 10.0.22621.0
IDEs:
  Android Studio: Not Found
  Visual Studio:
    - 17.6.33829.357 (Visual Studio Community 2022)
    - 16.11.33801.447 (Visual Studio Community 2019)
Languages:
  Java: Not Found
  Ruby: Not Found
npmPackages:
  "@react-native-community/cli": Not Found
  react:
    installed: 18.2.0
    wanted: 18.2.0
  react-native:
    installed: 0.73.0-nightly-20230721-ccc50ddd2
    wanted: 0.73.0-nightly-20230721-ccc50ddd2
  react-native-windows:
    installed: 0.0.0-canary.693
    wanted: 0.0.0-canary.693
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: true
  newArchEnabled: false
iOS:
  hermesEnabled: Not found
  newArchEnabled: Not found

Target Platform Version

None

Target Device(s)

No response

Visual Studio Version

None

Build Configuration

None

Snack, code example, screenshot, or link to a repository

No response

@microsoft-github-policy-service microsoft-github-policy-service bot added the Needs: Triage 🔍 New issue that needs to be reviewed by the issue management team (label applied by bot) label Aug 16, 2023
@chrisglein
Copy link
Member Author

chrisglein commented Aug 16, 2023

Confirmed that something like this would work, but not sure if it's the right design to add knowledge of text in the CompositionDynamicAutomationProvider rather than have it surfaced a different way:

    case UIA_NamePropertyId: {
      pRetVal->vt = VT_BSTR;

      bool useAccessibilityLabel = true;
      if (props->accessibilityLabel.empty()) {
        auto textView = std::static_pointer_cast<::Microsoft::ReactNative::ParagraphComponentView>(strongView);
        if (textView) {
          auto wideName = ::Microsoft::Common::Unicode::Utf8ToUtf16(textView->AccessibilityName());
          pRetVal->bstrVal = SysAllocString(wideName.c_str());
          useAccessibilityLabel = false;
        }
      }

      if (pRetVal->bstrVal == nullptr) {
        auto wideName = ::Microsoft::Common::Unicode::Utf8ToUtf16(props->accessibilityLabel);
        pRetVal->bstrVal = SysAllocString(wideName.c_str());
      }
      
      hr = pRetVal->bstrVal != nullptr ? S_OK : E_OUTOFMEMORY;
      break;
    }

Will follow up about the right way to do this.

Update: Built this instead: chrisglein@a58cc6d

@chrisglein chrisglein removed the Needs: Triage 🔍 New issue that needs to be reviewed by the issue management team (label applied by bot) label Aug 17, 2023
@chrisglein chrisglein added this to the 0.73 milestone Aug 17, 2023
@chrisglein chrisglein self-assigned this Aug 17, 2023
@jonthysell jonthysell added the New Architecture Broad category for issues that apply to the RN "new" architecture of Turbo Modules + Fabric label Mar 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Accessibility Area: Fabric Support Facebook Fabric Area: Text bug New Architecture Broad category for issues that apply to the RN "new" architecture of Turbo Modules + Fabric
Projects
Status: Done
2 participants