microsoft / react-native-windows

A framework for building native Windows apps with React.
https://microsoft.github.io/react-native-windows/
Other
16.28k stars 1.14k forks source link

When a control updates its accessibilityRole shows as an empty string #13858

Open chiaramooney opened 1 month ago

chiaramooney commented 1 month ago

Problem Description

If a control has a specified accessibilityRole, the role will correctly be seen in the control's BaseViewProps upon the control's first render. But any time the control needs to rerender (i.e. when a switch is toggled, a touchable runs an onPress action that changes its text, a TextInput's text is edited, etc), the accessibilityRole for the control's BaseViewProps becomes the empty string. The role data is no longer correctly being added to the control's BaseViewProps.

I've tested other accessibility props and this behavior does not happen. It only occurs with accessibilityRole.

When looking at the RCTPerformMountInstructions function, the newChildShadowView.props object which is used to call the UpdateProps function for each component, the accessibilityRole value is empty as well.

Steps To Reproduce

  1. Run playground-composition
  2. Edit simple.tsx to be a switch with the value and onChange prop specified so the Switch can correctly toggle.
  3. Set the accessibilityRole of the switch to "adjustable"
  4. Launch the app
  5. Open accessibility insights; the control type of the switch should be slider.
  6. Then toggle the switch; reopen accessibility insights to see the control type is now button (the default control type of a switch which is passed to UIA when accessibilityRole = "")

Expected Results

The control type of the Switch should be "slider" before and after the switch is toggled.

CLI version

N/A

Environment

N/A

Community Modules

No response

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

chrisglein commented 2 weeks ago

Question: Is there a fight over the value happening here between what's specified in JS and a value being driven from native? What's observed is that the JS value comes through the first time and after interaction the value goes empty. This is on Fabric. How the value and struct are passed out is pretty core Fabric code that's been stable for a while. We didn't have test coverage on accessibilityRole for Fabric specifically though, so unclear if it could have regressed earlier. In this repro to be clear the role is not changing. And it occurs across a variety of controls.

Check what we're doing in the overrides for these controls to see if we're not passing the prop in some situations. Double check that the value remains set in the JS with the React dev tools to eliminate the possibility of something going wrong in the JS. Check the forks for Pressable to see if there's a point of failure there. Try a non-interactive control with a role set.