From 5cb14efdf7ca0567fda2e5ed8d70e2bb4ab54ff8 Mon Sep 17 00:00:00 2001 From: TatianaKapos Date: Tue, 3 Sep 2024 13:54:59 -0700 Subject: [PATCH 1/7] switch to optimized text --- vnext/src-win/Libraries/Text/Text.windows.js | 786 +++++++++++-------- 1 file changed, 474 insertions(+), 312 deletions(-) diff --git a/vnext/src-win/Libraries/Text/Text.windows.js b/vnext/src-win/Libraries/Text/Text.windows.js index ef9da1b58f8..26b79cedbe9 100644 --- a/vnext/src-win/Libraries/Text/Text.windows.js +++ b/vnext/src-win/Libraries/Text/Text.windows.js @@ -4,16 +4,14 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * #7149 should be strict local - * @flow + * @flow strict-local * @format */ -import type {____TextStyle_Internal as TextStyleInternal} from '../StyleSheet/StyleSheetTypes'; import type {PressEvent} from '../Types/CoreEventTypes'; -import type {TextProps} from './TextProps'; +import type {NativeTextProps} from './TextNativeComponent'; +import type {PressRetentionOffset, TextProps} from './TextProps'; -import * as ReactNativeFeatureFlags from '../../src/private/featureflags/ReactNativeFeatureFlags'; import * as PressabilityDebug from '../Pressability/PressabilityDebug'; import usePressability from '../Pressability/usePressability'; import flattenStyle from '../StyleSheet/flattenStyle'; @@ -24,105 +22,432 @@ import {NativeText, NativeVirtualText} from './TextNativeComponent'; import * as React from 'react'; import {useContext, useMemo, useState} from 'react'; -const View = require('../Components/View/View'); +const View = require('../Components/View/View'); // [Windows] import {type TextStyleProp, type ViewStyleProp} from '../StyleSheet/StyleSheet'; // [Windows] +type TextForwardRef = React.ElementRef< + typeof NativeText | typeof NativeVirtualText, +>; + /** * Text is the fundamental component for displaying text. * * @see https://reactnative.dev/docs/text */ -const TextLegacy: React.AbstractComponent< - TextProps, - React.ElementRef, -> = React.forwardRef((props: TextProps, forwardedRef) => { - const { - accessible, - accessibilityLabel, - accessibilityLevel, // Windows - accessibilityPosInSet, // Windows - accessibilitySetSize, // Windows - accessibilityState, - allowFontScaling, - 'aria-busy': ariaBusy, - 'aria-checked': ariaChecked, - 'aria-disabled': ariaDisabled, - 'aria-expanded': ariaExpanded, - 'aria-label': ariaLabel, - 'aria-level': ariaLevel, // Windows - 'aria-posinset': ariaPosinset, // Windows - 'aria-setsize': ariaSetsize, // Windows - 'aria-selected': ariaSelected, - ellipsizeMode, - disabled, - id, - nativeID, - numberOfLines, - onLongPress, - onPress, - onPressIn, - onPressOut, - onResponderGrant, - onResponderMove, - onResponderRelease, - onResponderTerminate, - onResponderTerminationRequest, - onStartShouldSetResponder, - pressRetentionOffset, - selectable, - selectionColor, - suppressHighlighting, - style, - ...restProps - } = props; - - const [isHighlighted, setHighlighted] = useState(false); +const Text: React.AbstractComponent = + React.forwardRef( + ( + { + accessible, + accessibilityLabel, + accessibilityLevel, // Windows + accessibilityPosInSet, // Windows + accessibilitySetSize, // Windows + accessibilityState, + allowFontScaling, + 'aria-busy': ariaBusy, + 'aria-checked': ariaChecked, + 'aria-disabled': ariaDisabled, + 'aria-expanded': ariaExpanded, + 'aria-label': ariaLabel, + 'aria-level': ariaLevel, // Windows + 'aria-posinset': ariaPosinset, // Windows + 'aria-setsize': ariaSetsize, // Windows + 'aria-selected': ariaSelected, + children, + ellipsizeMode, + disabled, + id, + nativeID, + numberOfLines, + onLongPress, + onPress, + onPressIn, + onPressOut, + onResponderGrant, + onResponderMove, + onResponderRelease, + onResponderTerminate, + onResponderTerminationRequest, + onStartShouldSetResponder, + pressRetentionOffset, + selectable, + selectionColor, + suppressHighlighting, + style, + ...restProps + }: TextProps, + forwardedRef, + ) => { + const _accessibilityLabel = ariaLabel ?? accessibilityLabel; + const _accessibilityLevel = ariaLevel ?? accessibilityLevel; // Windows + const _accessibilityPosInSet = ariaPosinset ?? accessibilityPosInSet; // Windows + const _accessibilitySetSize = ariaSetsize ?? accessibilitySetSize; // Windows + + let _accessibilityState: ?TextProps['accessibilityState'] = + accessibilityState; + if ( + ariaBusy != null || + ariaChecked != null || + ariaDisabled != null || + ariaExpanded != null || + ariaSelected != null + ) { + if (_accessibilityState != null) { + _accessibilityState = { + busy: ariaBusy ?? _accessibilityState.busy, + checked: ariaChecked ?? _accessibilityState.checked, + disabled: ariaDisabled ?? _accessibilityState.disabled, + expanded: ariaExpanded ?? _accessibilityState.expanded, + selected: ariaSelected ?? _accessibilityState.selected, + }; + } else { + _accessibilityState = { + busy: ariaBusy, + checked: ariaChecked, + disabled: ariaDisabled, + expanded: ariaExpanded, + selected: ariaSelected, + }; + } + } + + const _accessibilityStateDisabled = _accessibilityState?.disabled; + const _disabled = disabled ?? _accessibilityStateDisabled; + + const isPressable = + (onPress != null || + onLongPress != null || + onStartShouldSetResponder != null) && + _disabled !== true; + + // TODO: Move this processing to the view configuration. + const _selectionColor = + selectionColor == null ? null : processColor(selectionColor); + + let _style = style; + if (__DEV__) { + if (PressabilityDebug.isEnabled() && onPress != null) { + _style = [style, {color: 'magenta'}]; + } + } + + let _numberOfLines = numberOfLines; + if (_numberOfLines != null && !(_numberOfLines >= 0)) { + if (__DEV__) { + console.error( + `'numberOfLines' in must be a non-negative number, received: ${_numberOfLines}. The value will be set to 0.`, + ); + } + _numberOfLines = 0; + } + + let _selectable = selectable; + + const processedStyle = flattenStyle(_style); + if (processedStyle != null) { + if (typeof processedStyle.fontWeight === 'number') { + // $FlowFixMe[cannot-write] + processedStyle.fontWeight = processedStyle.fontWeight.toString(); + } + + if (processedStyle.userSelect != null) { + _selectable = userSelectToSelectableMap[processedStyle.userSelect]; + // $FlowFixMe[cannot-write] + delete processedStyle.userSelect; + } + + if (processedStyle.verticalAlign != null) { + // $FlowFixMe[cannot-write] + processedStyle.textAlignVertical = + verticalAlignToTextAlignVerticalMap[processedStyle.verticalAlign]; + // $FlowFixMe[cannot-write] + delete processedStyle.verticalAlign; + } + } + + const _nativeID = id ?? nativeID; + + const hasTextAncestor = useContext(TextAncestor); + if (hasTextAncestor) { + if (isPressable) { + return ( + + ); + } - const _accessibilityLabel = ariaLabel ?? accessibilityLabel; - - let _accessibilityState: ?TextProps['accessibilityState'] = - accessibilityState; - if ( - ariaBusy != null || - ariaChecked != null || - ariaDisabled != null || - ariaExpanded != null || - ariaSelected != null - ) { - if (_accessibilityState != null) { - _accessibilityState = { - busy: ariaBusy ?? _accessibilityState.busy, - checked: ariaChecked ?? _accessibilityState.checked, - disabled: ariaDisabled ?? _accessibilityState.disabled, - expanded: ariaExpanded ?? _accessibilityState.expanded, - selected: ariaSelected ?? _accessibilityState.selected, - }; - } else { - _accessibilityState = { - busy: ariaBusy, - checked: ariaChecked, - disabled: ariaDisabled, - expanded: ariaExpanded, - selected: ariaSelected, + return ( + + {children} + + ); + } + + // If the disabled prop and accessibilityState.disabled are out of sync but not both in + // falsy states we need to update the accessibilityState object to use the disabled prop. + if ( + _disabled !== _accessibilityStateDisabled && + ((_disabled != null && _disabled !== false) || + (_accessibilityStateDisabled != null && + _accessibilityStateDisabled !== false)) + ) { + _accessibilityState = {..._accessibilityState, disabled: _disabled}; + } + + const _accessible = Platform.select({ + ios: accessible !== false, + android: + accessible == null + ? onPress != null || onLongPress != null + : accessible, + default: accessible, + }); + + let nativeText = null; + if (isPressable) { + nativeText = ( + + ); + } else { + nativeText = ( + + {children} + + ); + } + + // [Windows + let styleProps: ViewStyleProp = (style: any); + if ( + global.RN$Bridgeless !== true && // [Windows] Fabric text handles borders, but on paper we need to wrap it in an extra view + styleProps && + styleProps.borderColor && + (styleProps.borderWidth || + styleProps.borderBottomWidth || + styleProps.borderEndWidth || + styleProps.borderLeftWidth || + styleProps.borderRightWidth || + styleProps.borderStartWidth || + styleProps.borderTopWidth) + ) { + let textStyleProps = Array.isArray(styleProps) + ? // $FlowFixMe[underconstrained-implicit-instantiation] + flattenStyle(styleProps) + : styleProps; + let { + // $FlowFixMe[prop-missing] + margin, + // $FlowFixMe[prop-missing] + marginBottom, + // $FlowFixMe[prop-missing] + marginEnd, + // $FlowFixMe[prop-missing] + marginHorizontal, + // $FlowFixMe[prop-missing] + marginLeft, + // $FlowFixMe[prop-missing] + marginRight, + // $FlowFixMe[prop-missing] + marginStart, + // $FlowFixMe[prop-missing] + marginTop, + // $FlowFixMe[prop-missing] + marginVertical, + // $FlowFixMe[prop-missing] + padding, + // $FlowFixMe[prop-missing] + paddingBottom, + // $FlowFixMe[prop-missing] + paddingEnd, + // $FlowFixMe[prop-missing] + paddingHorizontal, + // $FlowFixMe[prop-missing] + paddingLeft, + // $FlowFixMe[prop-missing] + paddingRight, + // $FlowFixMe[prop-missing] + paddingStart, + // $FlowFixMe[prop-missing] + paddingTop, + // $FlowFixMe[prop-missing] + paddingVertical, + // $FlowFixMe[not-an-object] + ...rest + } = textStyleProps != null ? textStyleProps : {} + return ( + {nativeText} + ); }; - } - } + // Windows] + + if (children == null) { + return nativeText; + } + + // If the children do not contain a JSX element it would not be possible to have a + // nested `Text` component so we can skip adding the `TextAncestor` context wrapper + // which has a performance overhead. Since we do this for performance reasons we need + // to keep the check simple to avoid regressing overall perf. For this reason the + // `children.length` constant is set to `3`, this should be a reasonable tradeoff + // to capture the majority of `Text` uses but also not make this check too expensive. + if (Array.isArray(children) && children.length <= 3) { + let hasNonTextChild = false; + for (let child of children) { + if (child != null && typeof child === 'object') { + hasNonTextChild = true; + break; + } + } + if (!hasNonTextChild) { + return nativeText; + } + } else if (typeof children !== 'object') { + return nativeText; + } - const _accessibilityStateDisabled = _accessibilityState?.disabled; - const _disabled = disabled ?? _accessibilityStateDisabled; + return ( + {nativeText} + ); + }, + ); - const isPressable = - (onPress != null || - onLongPress != null || - onStartShouldSetResponder != null) && - _disabled !== true; +Text.displayName = 'Text'; - const initialized = useLazyInitialization(isPressable); - const config = useMemo(() => { - if (!initialized) { - return null; - } +type TextPressabilityProps = $ReadOnly<{ + onLongPress?: ?(event: PressEvent) => mixed, + onPress?: ?(event: PressEvent) => mixed, + onPressIn?: ?(event: PressEvent) => mixed, + onPressOut?: ?(event: PressEvent) => mixed, + onResponderGrant?: ?(event: PressEvent) => void, + onResponderMove?: ?(event: PressEvent) => void, + onResponderRelease?: ?(event: PressEvent) => void, + onResponderTerminate?: ?(event: PressEvent) => void, + onResponderTerminationRequest?: ?() => boolean, + onStartShouldSetResponder?: ?() => boolean, + pressRetentionOffset?: ?PressRetentionOffset, + suppressHighlighting?: ?boolean, +}>; + +/** + * Hook that handles setting up Pressability of Text components. + * + * NOTE: This hook is relatively expensive so it should only be used absolutely necessary. + */ +function useTextPressability({ + onLongPress, + onPress, + onPressIn, + onPressOut, + onResponderGrant, + onResponderMove, + onResponderRelease, + onResponderTerminate, + onResponderTerminationRequest, + onStartShouldSetResponder, + pressRetentionOffset, + suppressHighlighting, +}: TextPressabilityProps) { + const [isHighlighted, setHighlighted] = useState(false); + // Setup pressability config and wrap callbacks needs to track the highlight state. + const config = useMemo(() => { let _onPressIn = onPressIn; let _onPressOut = onPressOut; @@ -142,7 +467,7 @@ const TextLegacy: React.AbstractComponent< } return { - disabled: !isPressable, + disabled: false, pressRectOffset: pressRetentionOffset, onLongPress, onPress, @@ -150,8 +475,6 @@ const TextLegacy: React.AbstractComponent< onPressOut: _onPressOut, }; }, [ - initialized, - isPressable, pressRetentionOffset, onLongPress, onPress, @@ -160,7 +483,10 @@ const TextLegacy: React.AbstractComponent< suppressHighlighting, ]); + // Init the pressability class const eventHandlers = usePressability(config); + + // Create NativeText event handlers which proxy events to pressability const eventHandlersForText = useMemo( () => eventHandlers == null @@ -211,222 +537,67 @@ const TextLegacy: React.AbstractComponent< ], ); - // TODO: Move this processing to the view configuration. - const _selectionColor = - selectionColor == null ? null : processColor(selectionColor); + // Return the highlight state and NativeText event handlers + return useMemo( + () => [isHighlighted, eventHandlersForText], + [isHighlighted, eventHandlersForText], + ); +} - let _style = style; - if (__DEV__) { - if (PressabilityDebug.isEnabled() && onPress != null) { - _style = [style, {color: 'magenta'}]; - } - } +type NativePressableTextProps = $ReadOnly<{ + textProps: NativeTextProps, + textPressabilityProps: TextPressabilityProps, +}>; - let _numberOfLines = numberOfLines; - if (_numberOfLines != null && !(_numberOfLines >= 0)) { - if (__DEV__) { - console.error( - `'numberOfLines' in must be a non-negative number, received: ${_numberOfLines}. The value will be set to 0.`, - ); - } - _numberOfLines = 0; - } - - let _selectable = selectable; - const processedStyle = flattenStyle(_style); - if (processedStyle != null) { - if (typeof processedStyle.fontWeight === 'number') { - // $FlowFixMe[cannot-write] - processedStyle.fontWeight = processedStyle.fontWeight.toString(); - } - - if (processedStyle.userSelect != null) { - _selectable = userSelectToSelectableMap[processedStyle.userSelect]; - // $FlowFixMe[cannot-write] - delete processedStyle.userSelect; - } +/** + * Wrap the NativeVirtualText component and initialize pressability. + * + * This logic is split out from the main Text component to enable the more + * expensive pressability logic to be only initialized when needed. + */ +const NativePressableVirtualText: React.AbstractComponent< + NativePressableTextProps, + TextForwardRef, +> = React.forwardRef(({textProps, textPressabilityProps}, forwardedRef) => { + const [isHighlighted, eventHandlersForText] = useTextPressability( + textPressabilityProps, + ); - if (processedStyle.verticalAlign != null) { - // $FlowFixMe[cannot-write] - processedStyle.textAlignVertical = - verticalAlignToTextAlignVerticalMap[processedStyle.verticalAlign]; - // $FlowFixMe[cannot-write] - delete processedStyle.verticalAlign; - } - } - - const _nativeID = id ?? nativeID; - - // If the disabled prop and accessibilityState.disabled are out of sync but not both in - // falsy states we need to update the accessibilityState object to use the disabled prop. - if ( - _disabled !== _accessibilityStateDisabled && - ((_disabled != null && _disabled !== false) || - (_accessibilityStateDisabled != null && - _accessibilityStateDisabled !== false)) - ) { - _accessibilityState = {..._accessibilityState, disabled: _disabled}; - } - - const _accessible = Platform.select({ - ios: accessible !== false, - android: - accessible == null ? onPress != null || onLongPress != null : accessible, - default: accessible !== false, - }); - - const hasTextAncestor = useContext(TextAncestor); - if (hasTextAncestor) { - return ( - - ); - // [Windows] Following else statement forked due to PR #5740 - } else { - let styleProps: ViewStyleProp = (style: any); - if ( - global.RN$Bridgeless !== true && // [Windows] Fabric text handles borders, but on paper we need to wrap it in an extra view - styleProps && - styleProps.borderColor && - (styleProps.borderWidth || - styleProps.borderBottomWidth || - styleProps.borderEndWidth || - styleProps.borderLeftWidth || - styleProps.borderRightWidth || - styleProps.borderStartWidth || - styleProps.borderTopWidth) - ) { - let textStyleProps = Array.isArray(styleProps) - ? // $FlowFixMe[underconstrained-implicit-instantiation] - flattenStyle(styleProps) - : styleProps; - let { - // $FlowFixMe[prop-missing] - margin, - // $FlowFixMe[prop-missing] - marginBottom, - // $FlowFixMe[prop-missing] - marginEnd, - // $FlowFixMe[prop-missing] - marginHorizontal, - // $FlowFixMe[prop-missing] - marginLeft, - // $FlowFixMe[prop-missing] - marginRight, - // $FlowFixMe[prop-missing] - marginStart, - // $FlowFixMe[prop-missing] - marginTop, - // $FlowFixMe[prop-missing] - marginVertical, - // $FlowFixMe[prop-missing] - padding, - // $FlowFixMe[prop-missing] - paddingBottom, - // $FlowFixMe[prop-missing] - paddingEnd, - // $FlowFixMe[prop-missing] - paddingHorizontal, - // $FlowFixMe[prop-missing] - paddingLeft, - // $FlowFixMe[prop-missing] - paddingRight, - // $FlowFixMe[prop-missing] - paddingStart, - // $FlowFixMe[prop-missing] - paddingTop, - // $FlowFixMe[prop-missing] - paddingVertical, - // $FlowFixMe[not-an-object] - ...rest - } = textStyleProps != null ? textStyleProps : {}; - - let {style, ...textPropsLessStyle} = props; - return ( - - - - - - ); - } else { - return ( - - - - ); - } - } - // [Windows #5740] + return ( + + ); }); -TextLegacy.displayName = 'TextLegacy'; - /** - * Returns false until the first time `newValue` is true, after which this will - * always return true. This is necessary to lazily initialize `Pressability` so - * we do not eagerly create one for every pressable `Text` component. + * Wrap the NativeText component and initialize pressability. + * + * This logic is split out from the main Text component to enable the more + * expensive pressability logic to be only initialized when needed. */ -function useLazyInitialization(newValue: boolean): boolean { - const [oldValue, setValue] = useState(newValue); - if (!oldValue && newValue) { - setValue(newValue); - } - return oldValue; -} +const NativePressableText: React.AbstractComponent< + NativePressableTextProps, + TextForwardRef, +> = React.forwardRef(({textProps, textPressabilityProps}, forwardedRef) => { + const [isHighlighted, eventHandlersForText] = useTextPressability( + textPressabilityProps, + ); + + return ( + + ); +}); const userSelectToSelectableMap = { auto: true, @@ -443,13 +614,4 @@ const verticalAlignToTextAlignVerticalMap = { middle: 'center', }; -const Text: React.AbstractComponent< - TextProps, - React.ElementRef, -> = React.forwardRef((props: TextProps, forwardedRef) => { - return ; -}); - -Text.displayName = 'Text'; - module.exports = Text; \ No newline at end of file From 7e920eeaa1e1f919a2b8b93251c1aabb1b0929a3 Mon Sep 17 00:00:00 2001 From: TatianaKapos Date: Tue, 3 Sep 2024 13:59:19 -0700 Subject: [PATCH 2/7] Change files --- ...ative-windows-568a3722-a79f-42de-b83e-9b1f2dc6fd89.json | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 change/react-native-windows-568a3722-a79f-42de-b83e-9b1f2dc6fd89.json diff --git a/change/react-native-windows-568a3722-a79f-42de-b83e-9b1f2dc6fd89.json b/change/react-native-windows-568a3722-a79f-42de-b83e-9b1f2dc6fd89.json new file mode 100644 index 00000000000..f2be63840ee --- /dev/null +++ b/change/react-native-windows-568a3722-a79f-42de-b83e-9b1f2dc6fd89.json @@ -0,0 +1,7 @@ +{ + "type": "prerelease", + "comment": "switch to optimized text", + "packageName": "react-native-windows", + "email": "tatianakapos@microsoft.com", + "dependentChangeType": "patch" +} From 5685031f19a81b13abe91dabfd2ded205e30e16f Mon Sep 17 00:00:00 2001 From: TatianaKapos Date: Tue, 3 Sep 2024 16:34:29 -0700 Subject: [PATCH 3/7] fix lint --- vnext/src-win/Libraries/Text/Text.windows.js | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/vnext/src-win/Libraries/Text/Text.windows.js b/vnext/src-win/Libraries/Text/Text.windows.js index 26b79cedbe9..46db8e7e5ff 100644 --- a/vnext/src-win/Libraries/Text/Text.windows.js +++ b/vnext/src-win/Libraries/Text/Text.windows.js @@ -314,18 +314,19 @@ const Text: React.AbstractComponent = } // [Windows - let styleProps: ViewStyleProp = (style: any); + // $FlowFixMe[unclear-type] + let styleProps: ViewStyleProp = (style: any); // Flow style type casting if ( global.RN$Bridgeless !== true && // [Windows] Fabric text handles borders, but on paper we need to wrap it in an extra view styleProps && - styleProps.borderColor && - (styleProps.borderWidth || - styleProps.borderBottomWidth || - styleProps.borderEndWidth || - styleProps.borderLeftWidth || - styleProps.borderRightWidth || - styleProps.borderStartWidth || - styleProps.borderTopWidth) + styleProps.borderColor != null && + (styleProps.borderWidth != null || + styleProps.borderBottomWidth != null || + styleProps.borderEndWidth != null || + styleProps.borderLeftWidth != null || + styleProps.borderRightWidth != null || + styleProps.borderStartWidth != null || + styleProps.borderTopWidth != null) ) { let textStyleProps = Array.isArray(styleProps) ? // $FlowFixMe[underconstrained-implicit-instantiation] From 94e02c58ecf0c771412a78d1a056766c358e4a4f Mon Sep 17 00:00:00 2001 From: TatianaKapos Date: Tue, 3 Sep 2024 16:36:05 -0700 Subject: [PATCH 4/7] remove shortcut --- vnext/src-win/Libraries/Text/Text.windows.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/vnext/src-win/Libraries/Text/Text.windows.js b/vnext/src-win/Libraries/Text/Text.windows.js index 46db8e7e5ff..6db194aef8b 100644 --- a/vnext/src-win/Libraries/Text/Text.windows.js +++ b/vnext/src-win/Libraries/Text/Text.windows.js @@ -388,6 +388,7 @@ const Text: React.AbstractComponent = // to keep the check simple to avoid regressing overall perf. For this reason the // `children.length` constant is set to `3`, this should be a reasonable tradeoff // to capture the majority of `Text` uses but also not make this check too expensive. + /* if (Array.isArray(children) && children.length <= 3) { let hasNonTextChild = false; for (let child of children) { @@ -402,6 +403,7 @@ const Text: React.AbstractComponent = } else if (typeof children !== 'object') { return nativeText; } + */ return ( {nativeText} From 641dadaaca2b3d5ddcbb354dfef9ddb1b3712e6a Mon Sep 17 00:00:00 2001 From: TatianaKapos Date: Thu, 5 Sep 2024 14:22:19 -0700 Subject: [PATCH 5/7] fix accesible --- vnext/src-win/Libraries/Text/Text.windows.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vnext/src-win/Libraries/Text/Text.windows.js b/vnext/src-win/Libraries/Text/Text.windows.js index 6db194aef8b..5844e704dc8 100644 --- a/vnext/src-win/Libraries/Text/Text.windows.js +++ b/vnext/src-win/Libraries/Text/Text.windows.js @@ -246,7 +246,7 @@ const Text: React.AbstractComponent = accessible == null ? onPress != null || onLongPress != null : accessible, - default: accessible, + default: accessible !== false, // [Windows] }); let nativeText = null; From 605043d3a25f25c060b1be054e5912fde91caca0 Mon Sep 17 00:00:00 2001 From: TatianaKapos Date: Thu, 5 Sep 2024 14:26:05 -0700 Subject: [PATCH 6/7] apply fix to win32 --- .../react-native-win32/src-win/Libraries/Text/Text.win32.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/@office-iss/react-native-win32/src-win/Libraries/Text/Text.win32.js b/packages/@office-iss/react-native-win32/src-win/Libraries/Text/Text.win32.js index c3e556defd2..414666a87fa 100644 --- a/packages/@office-iss/react-native-win32/src-win/Libraries/Text/Text.win32.js +++ b/packages/@office-iss/react-native-win32/src-win/Libraries/Text/Text.win32.js @@ -273,7 +273,7 @@ const Text: React.AbstractComponent = accessible == null ? onPress != null || onLongPress != null : accessible, - default: accessible, + default: accessible !== false, // Win32 }); let nativeText = null; From f5840992e4b6ee9a38d04a76f3df4f9fe004c93d Mon Sep 17 00:00:00 2001 From: TatianaKapos Date: Thu, 5 Sep 2024 15:02:30 -0700 Subject: [PATCH 7/7] Change files --- ...-native-win32-31b7128e-4580-4b52-84f9-83612d31222e.json | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 change/@office-iss-react-native-win32-31b7128e-4580-4b52-84f9-83612d31222e.json diff --git a/change/@office-iss-react-native-win32-31b7128e-4580-4b52-84f9-83612d31222e.json b/change/@office-iss-react-native-win32-31b7128e-4580-4b52-84f9-83612d31222e.json new file mode 100644 index 00000000000..44e59d6cda4 --- /dev/null +++ b/change/@office-iss-react-native-win32-31b7128e-4580-4b52-84f9-83612d31222e.json @@ -0,0 +1,7 @@ +{ + "type": "prerelease", + "comment": "switch to optimized text", + "packageName": "@office-iss/react-native-win32", + "email": "tatianakapos@microsoft.com", + "dependentChangeType": "patch" +}