Skip to content

Commit f004cd3

Browse files
iamAbhi-916facebook-github-bot
authored andcommitted
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: #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
1 parent 0d2e0ab commit f004cd3

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

packages/react-native/ReactCommon/react/renderer/components/text/ParagraphProps.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ void ParagraphProps::setProp(
135135
}
136136

137137
switch (hash) {
138-
RAW_SET_PROP_SWITCH_CASE_BASIC(isSelectable);
138+
RAW_SET_PROP_SWITCH_CASE(isSelectable, "selectable");
139139
RAW_SET_PROP_SWITCH_CASE_BASIC(onTextLayout);
140140
}
141141

@@ -154,7 +154,7 @@ SharedDebugStringConvertibleList ParagraphProps::getDebugProps() const {
154154
return ViewProps::getDebugProps() + BaseTextProps::getDebugProps() +
155155
paragraphAttributes.getDebugProps() +
156156
SharedDebugStringConvertibleList{
157-
debugStringConvertibleItem("isSelectable", isSelectable)};
157+
debugStringConvertibleItem("selectable", isSelectable)};
158158
}
159159
#endif
160160

0 commit comments

Comments
 (0)