Text: Fix isSelectable prop macro conversion (#52599)

Summary:
for IOS and React native windows we can observe that the macro conversion is incorrect in ParagraphProps particularly for selectable prop.

current conversion
```
case ([]() constexpr -> RawPropsPropNameHash {   return facebook::react::fnv1a("isSelectable");  }()): fromRawValue(context, value, isSelectable, defaults.isSelectable); return;
```
issue is that isSelectable is not the raw prop therefore JS to native flow for the prop is not correct .
(Note : this works for Android as ReactProp(name = "selectable"):  https://github.com/facebook/react-native/blob/bbc1e121c71d14803d29a931f642bf8ea6ee2023/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/text/ReactTextAnchorViewManager.kt#L97-L100 )

fix
```
RAW_SET_PROP_SWITCH_CASE(isSelectable, selectable)
```

Current implementation selectable prop is not working for IOS and React native windows as the macro conversion is incorrect in ParagraphProps particularly for selectable prop.

## Changelog:
Updated ParagraphProps macro conversion for isSelectable , keeping it backward compatible.

<!-- Help reviewers and the release process by writing your own changelog entry.

Pick one each for the category and type tags:
[IOS] [FIXED] - Fix selectable prop not working correctly
[ANDROID|GENERAL|IOS|INTERNAL] [BREAKING|ADDED|CHANGED|DEPRECATED|REMOVED|FIXED|SECURITY] - Message

For more details, see:
https://reactnative.dev/contributing/changelogs-in-pull-requests

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

Test Plan:
Tested on react native windows playground

Sample code

```
export default class Bootstrap extends React.Component {
  render() {
    return (
      <View style={styles.container}>
        <Text style={styles.header}>Selectable vs Non-Selectable Text</Text>

        <Text selectable={true} style={styles.text}>
           This text is selectable. You can long-press and copy it.
        </Text>

        <Text selectable={false} style={styles.text}>
           This text is not selectable. You cannot copy it.
        </Text>
      </View>
    );
  }
}

```
before fix debug output  , native unaware of selectable prop values from JS
```
ReactNative ['Samples\text'] (info): ''[Text.js] NativeText _selectable:', true'
ReactNative ['Samples\text'] (info): ''[Text.js] NativeText _selectable:', false'
[ParagraphComponentView] updateProps - old isSelectable: 0, new isSelectable: 0
[ParagraphComponentView] DrawText - isSelectable: 0
[ParagraphComponentView] DrawText - selection logic would be DISABLED here.
[ParagraphComponentView] updateProps - old isSelectable: 0, new isSelectable: 0
[ParagraphComponentView] DrawText - isSelectable: 0
[ParagraphComponentView] DrawText - selection logic would be DISABLED here.
[ParagraphComponentView] updateProps - old isSelectable: 0, new isSelectable: 0
[ParagraphComponentView] DrawText - isSelectable: 0
[ParagraphComponentView] DrawText - selection logic would be DISABLED here.

```

after fix debug output , native picks up selectable prop values from JS correctly
```
ReactNative ['Samples\text'] (info): ''[Text.js] NativeText _selectable:', true'
ReactNative ['Samples\text'] (info): ''[Text.js] NativeText _selectable:', false'
[ParagraphComponentView] updateProps - old selectable: 0, new selectable: 0
[ParagraphComponentView] DrawText - selectable: 0
[ParagraphComponentView] DrawText - selection logic would be DISABLED here.
[ParagraphComponentView] updateProps - old selectable: 0, new selectable: 1
[ParagraphComponentView] DrawText - selectable: 1
[ParagraphComponentView] DrawText - selection logic would be enabled here.
[ParagraphComponentView] updateProps - old selectable: 0, new selectable: 0
[ParagraphComponentView] DrawText - selectable: 0
[ParagraphComponentView] DrawText - selection logic would be DISABLED here.
```

Reviewed By: rozele

Differential Revision: D78333906

Pulled By: javache

fbshipit-source-id: 4d2f9ea591e991b1aed126e9fed72fdfe1a49ce9
This commit is contained in:
Abhijeet Jha
2025-07-15 04:41:55 -07:00
committed by Facebook GitHub Bot
parent 0d2e0abc45
commit f004cd39bc
@@ -135,7 +135,7 @@ void ParagraphProps::setProp(
}
switch (hash) {
RAW_SET_PROP_SWITCH_CASE_BASIC(isSelectable);
RAW_SET_PROP_SWITCH_CASE(isSelectable, "selectable");
RAW_SET_PROP_SWITCH_CASE_BASIC(onTextLayout);
}
@@ -154,7 +154,7 @@ SharedDebugStringConvertibleList ParagraphProps::getDebugProps() const {
return ViewProps::getDebugProps() + BaseTextProps::getDebugProps() +
paragraphAttributes.getDebugProps() +
SharedDebugStringConvertibleList{
debugStringConvertibleItem("isSelectable", isSelectable)};
debugStringConvertibleItem("selectable", isSelectable)};
}
#endif