Skip to content

In native code, there is no way to determine unset selected vs selected: false #46988

Open
@chiaramooney

Description

@chiaramooney

Description

From the JS, the developer has the choice to specify the accessibilityState prop. Then, they can specify any subset of 'busy', 'expanded', 'selected', 'disabled', and 'checked'.

In the JS `selected' can be undefined or a boolean value. However, once the data is passed to the native code, accessibilityState->selected always takes a boolean value. There is no way to determine in the native code if the user has not set the 'selected' state (i.e. the control does not have selectable behavior) or if they have set 'selected' to false (i.e. the control does have selectable behavior but it is not selected)

Could we change the 'selected' value in the accessibilityState to be an std::optional, so the 'undefined' state of selected could be preserved on the native side? This change is needed to implement correct accessibility behavior on Windows.

Steps to reproduce

Set a control to have accessibilityState={{}} and accessibilityState={{selected: false}}. Both show the same data for props->accessibilityState

React Native Version

nightly

Affected Platforms

Other (please specify)

Output of npx react-native info

N/A

Stacktrace or Logs

N/A

Reproducer

https://snack.expo.dev/5HM2iIVtfaUY5z1FeHDgm

Screenshots and Videos

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions