Do not include an expanded property by default in accessibilityState (#56814)

Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/56814

Any time we have a non-nullable accessibilityState prop, it appears to always set `expanded` false, which causes most Android screen readers to append or prepend "collapsed". This fixes the issue.

## Changelog
[Android][Fixed] Screen reader behavior for accessibilityState expanded

Reviewed By: javache

Differential Revision: D105035390

fbshipit-source-id: 4b3b1b2a9b6e661cfde0f39d7de6a7cd7af91bb0
This commit is contained in:
Eric Rozell authored and meta-codesync[bot] committed 2026-05-13 14:14:17 -07:00
1 parent 37be9351c8
commit fafcfcd5f6
1 file changed
+3 -2
@@ -456,8 +456,9 @@ inline static void updateAccessibilityStateProp(
}
if (!oldState.has_value() || newState->expanded != oldState->expanded) {
resultState["expanded"] =
newState->expanded.has_value() && newState->expanded.value();
if (newState->expanded.has_value()) {
resultState["expanded"] = newState->expanded.value();
}
}
if (!oldState.has_value() || newState->checked != oldState->checked) {