Skip to content

Fixes CSS transform styles applied directly to <Text> components are silently ignored on iOS when using the new architecture#56002

Open
Adityakk9031 wants to merge 2 commits into
react:mainfrom
Adityakk9031:#55306
Open

Fixes CSS transform styles applied directly to <Text> components are silently ignored on iOS when using the new architecture#56002
Adityakk9031 wants to merge 2 commits into
react:mainfrom
Adityakk9031:#55306

Conversation

@Adityakk9031

@Adityakk9031 Adityakk9031 commented Mar 9, 2026

Copy link
Copy Markdown

Fixes #55306
Root Cause
On iOS, a node does not form a dedicated UIView by default. It is "flattened" into its parent component as an NSAttributedString fragment, controlled by the ShadowNodeTraits::Trait::FormsView flag. Since there is no backing UIView or CALayer, any transform prop applied to has nothing to act on and is silently ignored.

On Android, all nodes always set FormsView (unconditionally), which is why the transform works there — this asymmetry was the root cause.

cpp
// Before fix: FormsView only ever set on Android
static ShadowNodeTraits BaseTraits() {
auto traits = ConcreteShadowNode::BaseTraits();
#ifdef ANDROID
traits.set(ShadowNodeTraits::Trait::FormsView); // ← iOS never reaches here!
#endif
return traits;
}
Fix
Three files were changed:

TextProps.h
— Added Transform transform and TransformOrigin transformOrigin fields. Previously
TextProps
only inherited from
Props
+
BaseTextProps
(not
BaseViewProps
), so it had no transform field at all.

TextProps.cpp
— Parse transform and transformOrigin from raw JS props in the constructor and in
setProp
, mirroring
BaseViewProps
.

TextShadowNode.h
— On iOS, added a custom constructor that checks textProps->transform.operations.empty(). If the user supplied a transform, it sets ShadowNodeTraits::Trait::FormsView before delegating to BaseShadowNode, forcing Fabric to generate a real UIView for that text node so the transform can be applied.

This is zero-cost for non-transformed nodes — they continue to be flattened as before with no performance regression.

Changelog:
[IOS] [FIXED] - CSS transform styles applied to components are now correctly applied on iOS in the new architecture (Fabric), matching Android behavior.

Test Plan:
Repro steps (iOS Simulator, macOS + Xcode required)
Clone and build the RNTester app with this fix on an iOS Simulator.
Create a component with a directly-transformed :
jsx
<Text style={{ transform: [{ translateY: 50 }] }}>
Transformed text

Before fix: Text is not translated — it renders at its default position.
After fix: Text is translated 50pt downward, matching Android behavior.

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Mar 9, 2026
@Adityakk9031 Adityakk9031 changed the title #55306 Fixes CSS transform styles applied directly to <Text> components are silently ignored on iOS when using the new architecture Mar 9, 2026
@facebook-github-bot facebook-github-bot added the Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team. label Mar 9, 2026
@Adityakk9031

Copy link
Copy Markdown
Author

@christophpurrer sir please have a look

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

style transform on Text component inconsistently applied on iOS

2 participants