Skip to content

Allow pseudo-element shadow node lookup in JS (#56455)#56455

Closed
zeyap wants to merge 3 commits intofacebook:mainfrom
zeyap:export-D98982251
Closed

Allow pseudo-element shadow node lookup in JS (#56455)#56455
zeyap wants to merge 3 commits intofacebook:mainfrom
zeyap:export-D98982251

Conversation

@zeyap
Copy link
Copy Markdown
Contributor

@zeyap zeyap commented Apr 15, 2026

Summary:

Changelog:

[Internal] [Added] - Allow pseudo-element shadow node lookup in JS

Add findPseudoElementShadowNodeByTag to look up pseudo-element shadow nodes by tag from JS, and update the animation helper to connect animated nodes to pseudo-element shadow nodes for old-element animations.

Key changes:

  • Add findPseudoElementShadowNodeByTag(tag) virtual method to UIManagerViewTransitionDelegate and implement in ViewTransitionModule (linear scan over oldPseudoElementNodes_)
  • Expose the method via NativeViewTransition TurboModule so JS can resolve a pseudo-element's shadow node by its native tag
  • Add findPseudoElementShadowNodeByTag to NativeViewTransition.js specs

Reviewed By: sammy-SC

Differential Revision: D98982251

@meta-codesync
Copy link
Copy Markdown

meta-codesync bot commented Apr 15, 2026

@zeyap has exported this pull request. If you are a Meta employee, you can view the originating Diff in D98982251.

@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 Apr 15, 2026
@meta-codesync meta-codesync bot changed the title Allow pseudo-element shadow node lookup in JS Allow pseudo-element shadow node lookup in JS (#56455) Apr 15, 2026
@zeyap zeyap force-pushed the export-D98982251 branch from 50b2bff to 625d667 Compare April 15, 2026 17:42
zeyap added a commit to zeyap/react-native that referenced this pull request Apr 15, 2026
Summary:

## Changelog:

[Internal] [Added] - Allow pseudo-element shadow node lookup in JS

Add `findPseudoElementShadowNodeByTag` to look up pseudo-element shadow nodes by tag from JS, and update the animation helper to connect animated nodes to pseudo-element shadow nodes for old-element animations.

Key changes:
- Add `findPseudoElementShadowNodeByTag(tag)` virtual method to `UIManagerViewTransitionDelegate` and implement in `ViewTransitionModule` (linear scan over `oldPseudoElementNodes_`)
- Expose the method via `NativeViewTransition` TurboModule so JS can resolve a pseudo-element's shadow node by its native tag
- Add `findPseudoElementShadowNodeByTag` to `NativeViewTransition.js` spec
- Update `ViewTransitionAnimationHelper.js`:
  - `animateInternal` accepts a new `pseudo` parameter (`'old'` | `'new'`)
  - When `pseudo === 'old'`, use `findPseudoElementShadowNodeByTag` instead of `findShadowNodeByTag_DEPRECATED` to connect animated nodes to the correct shadow node family
  - Pass `'new'` for enter animations and propagate `_pseudo` from pseudo-element objects for exit animations

Reviewed By: sammy-SC

Differential Revision: D98982251
zeyap added a commit to zeyap/react-native that referenced this pull request Apr 15, 2026
Summary:

## Changelog:

[Internal] [Added] - Allow pseudo-element shadow node lookup in JS

Add `findPseudoElementShadowNodeByTag` to look up pseudo-element shadow nodes by tag from JS, and update the animation helper to connect animated nodes to pseudo-element shadow nodes for old-element animations.

Key changes:
- Add `findPseudoElementShadowNodeByTag(tag)` virtual method to `UIManagerViewTransitionDelegate` and implement in `ViewTransitionModule` (linear scan over `oldPseudoElementNodes_`)
- Expose the method via `NativeViewTransition` TurboModule so JS can resolve a pseudo-element's shadow node by its native tag
- Add `findPseudoElementShadowNodeByTag` to `NativeViewTransition.js` spec
- Update `ViewTransitionAnimationHelper.js`:
  - `animateInternal` accepts a new `pseudo` parameter (`'old'` | `'new'`)
  - When `pseudo === 'old'`, use `findPseudoElementShadowNodeByTag` instead of `findShadowNodeByTag_DEPRECATED` to connect animated nodes to the correct shadow node family
  - Pass `'new'` for enter animations and propagate `_pseudo` from pseudo-element objects for exit animations

Reviewed By: sammy-SC

Differential Revision: D98982251
zeyap added a commit to zeyap/react-native that referenced this pull request Apr 15, 2026
Summary:
Pull Request resolved: facebook#56455

## Changelog:

[Internal] [Added] - Allow pseudo-element shadow node lookup in JS

Add `findPseudoElementShadowNodeByTag` to look up pseudo-element shadow nodes by tag from JS, and update the animation helper to connect animated nodes to pseudo-element shadow nodes for old-element animations.

Key changes:
- Add `findPseudoElementShadowNodeByTag(tag)` virtual method to `UIManagerViewTransitionDelegate` and implement in `ViewTransitionModule` (linear scan over `oldPseudoElementNodes_`)
- Expose the method via `NativeViewTransition` TurboModule so JS can resolve a pseudo-element's shadow node by its native tag
- Add `findPseudoElementShadowNodeByTag` to `NativeViewTransition.js` spec
- Update `ViewTransitionAnimationHelper.js`:
  - `animateInternal` accepts a new `pseudo` parameter (`'old'` | `'new'`)
  - When `pseudo === 'old'`, use `findPseudoElementShadowNodeByTag` instead of `findShadowNodeByTag_DEPRECATED` to connect animated nodes to the correct shadow node family
  - Pass `'new'` for enter animations and propagate `_pseudo` from pseudo-element objects for exit animations

Reviewed By: sammy-SC

Differential Revision: D98982251
@zeyap zeyap force-pushed the export-D98982251 branch 2 times, most recently from ce38014 to 61edf46 Compare April 15, 2026 19:48
zeyap added a commit to zeyap/react-native that referenced this pull request Apr 15, 2026
Summary:

## Changelog:

[Internal] [Added] - Allow pseudo-element shadow node lookup in JS

Add `findPseudoElementShadowNodeByTag` to look up pseudo-element shadow nodes by tag from JS, and update the animation helper to connect animated nodes to pseudo-element shadow nodes for old-element animations.

Key changes:
- Add `findPseudoElementShadowNodeByTag(tag)` virtual method to `UIManagerViewTransitionDelegate` and implement in `ViewTransitionModule` (linear scan over `oldPseudoElementNodes_`)
- Expose the method via `NativeViewTransition` TurboModule so JS can resolve a pseudo-element's shadow node by its native tag
- Add `findPseudoElementShadowNodeByTag` to `NativeViewTransition.js` specs

Reviewed By: sammy-SC

Differential Revision: D98982251
zeyap added 3 commits April 15, 2026 13:04
…ebook#56456)

Summary:

## Changelog:

[Internal] [Added] - Support pseudo-element shadow node creation for view transitions

Implement `createViewTransitionInstance`, which is invoked by the React reconciler to create pseudo-element shadow nodes that visually represent the old state of elements participating in a view transition.

Key changes:
- Add `createViewTransitionInstance` JSI binding in `UIManagerBinding`, accepting a transition name and pseudo-element tag
- Add virtual `createViewTransitionInstance` method to `UIManagerViewTransitionDelegate`
- Implement the method in `ViewTransitionModule`: creates an absolutely-positioned, non-interactive `View` shadow node matching the old element's layout metrics (position, size)
- Manage two pseudo-element node maps: `oldPseudoElementNodes_` for the current transition and `oldPseudoElementNodesForNextTransition_` for entering nodes that may exit in a future transition
- Update `getOldViewTransitionInstance` to return the pseudo-element's tag (instead of the original element's tag) when a pseudo-element exists
- Add `applySnapshotsOnPseudoElementShadowNodes` stub for future platform-level bitmap snapshot integration

`createViewTransitionInstance` is typically called after `applyViewTransitionName` in the React reconciler. See the diagram below for the full flow.

{F1987481080}

Reviewed By: Abbondanzo

Differential Revision: D98981886
Summary:

## Changelog:

[Internal] [Added] - Append pseudo-element shadow nodes to root at commit

Append view transition pseudo-element shadow nodes to the root's children at commit time (`shadowTreeWillCommit`), so they are committed into the shadow tree and rendered by the platform.

Key changes:
- Add `getPseudoElementNodes(surfaceId)` virtual method to `UIManagerViewTransitionDelegate`, returning pseudo-element shadow nodes filtered by surface ID
- Implement the method in `ViewTransitionModule`, iterating over `oldPseudoElementNodes_` and collecting nodes matching the given surface
- In `shadowTreeWillCommit`, when view transitions are enabled, query the delegate for pseudo-element nodes and insert them at the end of `rootChildren` before committing

This ensures pseudo-element nodes (created by `createViewTransitionInstance`) are included in the committed shadow tree and ultimately mounted as platform views that display old-element snapshots during transitions.

## alternatives considered

we could also create pseudo element shadow node at React level, but (1) it doesn't make sense to have pseudo element Fiber node type in React just for RN use case, since web doesn't have it, (2) there's no React component mapped to the pseudo element on web, so it's more like something managed on the platform

Reviewed By: sammy-SC

Differential Revision: D98982122
Summary:

## Changelog:

[Internal] [Added] - Allow pseudo-element shadow node lookup in JS

Add `findPseudoElementShadowNodeByTag` to look up pseudo-element shadow nodes by tag from JS, and update the animation helper to connect animated nodes to pseudo-element shadow nodes for old-element animations.

Key changes:
- Add `findPseudoElementShadowNodeByTag(tag)` virtual method to `UIManagerViewTransitionDelegate` and implement in `ViewTransitionModule` (linear scan over `oldPseudoElementNodes_`)
- Expose the method via `NativeViewTransition` TurboModule so JS can resolve a pseudo-element's shadow node by its native tag
- Add `findPseudoElementShadowNodeByTag` to `NativeViewTransition.js` specs

Reviewed By: sammy-SC

Differential Revision: D98982251
@zeyap zeyap force-pushed the export-D98982251 branch from 61edf46 to 756d1d5 Compare April 15, 2026 20:04
zeyap added a commit to zeyap/react-native that referenced this pull request Apr 15, 2026
Summary:

## Changelog:

[Internal] [Added] - Allow pseudo-element shadow node lookup in JS

Add `findPseudoElementShadowNodeByTag` to look up pseudo-element shadow nodes by tag from JS, and update the animation helper to connect animated nodes to pseudo-element shadow nodes for old-element animations.

Key changes:
- Add `findPseudoElementShadowNodeByTag(tag)` virtual method to `UIManagerViewTransitionDelegate` and implement in `ViewTransitionModule` (linear scan over `oldPseudoElementNodes_`)
- Expose the method via `NativeViewTransition` TurboModule so JS can resolve a pseudo-element's shadow node by its native tag
- Add `findPseudoElementShadowNodeByTag` to `NativeViewTransition.js` specs

Reviewed By: sammy-SC

Differential Revision: D98982251
zeyap added a commit to zeyap/react-native that referenced this pull request Apr 15, 2026
Summary:

## Changelog:

[Internal] [Added] - Allow pseudo-element shadow node lookup in JS

Add `findPseudoElementShadowNodeByTag` to look up pseudo-element shadow nodes by tag from JS, and update the animation helper to connect animated nodes to pseudo-element shadow nodes for old-element animations.

Key changes:
- Add `findPseudoElementShadowNodeByTag(tag)` virtual method to `UIManagerViewTransitionDelegate` and implement in `ViewTransitionModule` (linear scan over `oldPseudoElementNodes_`)
- Expose the method via `NativeViewTransition` TurboModule so JS can resolve a pseudo-element's shadow node by its native tag
- Add `findPseudoElementShadowNodeByTag` to `NativeViewTransition.js` specs

Reviewed By: sammy-SC

Differential Revision: D98982251
@meta-codesync meta-codesync bot closed this in 986be4c Apr 16, 2026
@facebook-github-tools facebook-github-tools bot added the Merged This PR has been merged. label Apr 16, 2026
@meta-codesync
Copy link
Copy Markdown

meta-codesync bot commented Apr 16, 2026

This pull request has been merged in 986be4c.

@react-native-bot
Copy link
Copy Markdown
Collaborator

This pull request was successfully merged by @zeyap in 986be4c

When will my fix make it into a release? | How to file a pick request?

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. fb-exported Merged This PR has been merged. meta-exported p: Facebook Partner: Facebook Partner

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants