From 6ab7ab34e56411a7e87f396feb2f7ece1c4f98dd Mon Sep 17 00:00:00 2001 From: fabriziobertoglio1987 <fabrizio.bertoglio@gmail.com> Date: Wed, 9 Feb 2022 14:31:46 +0800 Subject: [PATCH] moving logic to javascript --- Libraries/Text/Text.js | 13 ++++++++++++- .../views/text/ReactTextAnchorViewManager.java | 5 ----- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/Libraries/Text/Text.js b/Libraries/Text/Text.js index 7e0d5734929651..35c7d1bc2bf01f 100644 --- a/Libraries/Text/Text.js +++ b/Libraries/Text/Text.js @@ -48,11 +48,20 @@ const Text: React.AbstractComponent< const [isHighlighted, setHighlighted] = useState(false); + const _disabled = + restProps.disabled != null + ? restProps.disabled + : props.accessibilityState?.disabled; + const _accessibilityState = + _disabled !== props.accessibilityState?.disabled + ? {...props.accessibilityState, disabled: _disabled} + : props.accessibilityState; + const isPressable = (onPress != null || onLongPress != null || onStartShouldSetResponder != null) && - restProps.disabled !== true; + _disabled !== true; const initialized = useLazyInitialization(isPressable); const config = useMemo( @@ -174,7 +183,9 @@ const Text: React.AbstractComponent< <NativeText {...restProps} {...eventHandlersForText} + disabled={_disabled} accessible={accessible !== false} + accessibilityState={_accessibilityState} allowFontScaling={allowFontScaling !== false} ellipsizeMode={ellipsizeMode ?? 'tail'} isHighlighted={isHighlighted} diff --git a/ReactAndroid/src/main/java/com/facebook/react/views/text/ReactTextAnchorViewManager.java b/ReactAndroid/src/main/java/com/facebook/react/views/text/ReactTextAnchorViewManager.java index 06cd9c5853e14e..10e0f8cd19c10f 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/views/text/ReactTextAnchorViewManager.java +++ b/ReactAndroid/src/main/java/com/facebook/react/views/text/ReactTextAnchorViewManager.java @@ -43,11 +43,6 @@ public abstract class ReactTextAnchorViewManager<T extends View, C extends React }; private static final String TAG = "ReactTextAnchorViewManager"; - @ReactProp(name = "accessible") - public void setAccessible(ReactTextView view, boolean accessible) { - view.setFocusable(accessible); - } - // maxLines can only be set in master view (block), doesn't really make sense to set in a span @ReactProp(name = ViewProps.NUMBER_OF_LINES, defaultInt = ViewDefaults.NUMBER_OF_LINES) public void setNumberOfLines(ReactTextView view, int numberOfLines) {