fix(transforms): enable transforms on new arch and fix hit testing on both arches#2866
Merged
Saadnajmi merged 6 commits intomicrosoft:mainfrom Mar 23, 2026
Merged
Conversation
|
753b289 to
c2c71f2
Compare
…nd hit testing fixes
On macOS, AppKit resets layer.transform to identity during its display
cycle because NSView has no built-in transform property. This adds a
transform3D property to RCTUIView that persists the transform and
re-applies it in updateLayer.
Also fixes two related issues in the compat layer:
- Compensates for macOS layer.anchorPoint defaulting to {0,0} instead
of {0.5, 0.5}, so transforms apply from the view's center.
- Uses CALayer coordinate conversion in hitTest: and
RCTUIViewHitTestWithEvent, which correctly accounts for layer.transform
(NSView's convertPoint:fromView: does not).
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Use self.transform3D instead of self.layer.transform on macOS in RCTViewComponentView, which routes through RCTUIView's persistence and anchor point compensation. Remove duplicated anchor point compensation and hitTest: override that are now handled by RCTUIView. Update hit testing callers to use the new RCTUIViewHitTestWithEvent signature with fromView parameter. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…dinate conversion Update RCTUIViewHitTestWithEvent callers in Paper architecture to use the new fromView parameter, enabling transform-aware hit testing in old architecture as well. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
fc041d7 to
08dc34e
Compare
Saadnajmi
commented
Mar 21, 2026
packages/react-native/React/Fabric/Mounting/ComponentViews/View/RCTViewComponentView.mm
Outdated
Show resolved
Hide resolved
Saadnajmi
commented
Mar 22, 2026
packages/react-native/React/Fabric/Mounting/ComponentViews/View/RCTViewComponentView.mm
Outdated
Show resolved
Hide resolved
vmoroz
approved these changes
Mar 23, 2026
Saadnajmi
commented
Mar 23, 2026
packages/react-native/React/Fabric/Mounting/ComponentViews/View/RCTViewComponentView.mm
Show resolved
Hide resolved
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
CSS transforms (
rotate,scale,translateX, etc.) were not rendering on macOS with the New Architecture (Fabric). This PR fixes the root cause and related issues.Root Cause
On macOS,
NSViewhas no built-intransformproperty (unlikeUIViewon iOS). AppKit's layer-backed view system resetslayer.transformto identity during its layout/display cycle. This means any transform set on the layer is silently discarded.Changes
1. Add
transform3Dproperty toRCTUIViewwith anchor point and hit testing fixesupdateLayer(called during AppKit's display phase)wantsUpdateLayeris conditional on having a custom transform ordisplayLayer:delegate, sodrawRect:still works for text viewslayer.anchorPointdefaulting to{0, 0}instead of{0.5, 0.5}, so transforms apply from the view's centerhitTest:andRCTUIViewHitTestWithEventuseCALayercoordinate conversion, which correctly accounts forlayer.transform(NSView'sconvertPoint:fromView:does not)2. Use
transform3Din Fabric component viewsRCTViewComponentViewusesself.transform3Dinstead ofself.layer.transformon macOShitTest:override now handled byRCTUIView3. Update Paper hit testing callers for transform-aware coordinate conversion
RCTUIViewHitTestWithEventcallers in Paper architecture to use the newfromViewparameter, enabling transform-aware hit testing in old architecture as wellTest Plan
wantsUpdateLayerprevents skippingdrawRect:)🤖 Generated with Claude Code