Skip to content

Support light/dark mode toggling via Emulation.setEmulatedMedia (#56510)#56510

Closed
huntie wants to merge 1 commit intofacebook:mainfrom
huntie:export-D101624433
Closed

Support light/dark mode toggling via Emulation.setEmulatedMedia (#56510)#56510
huntie wants to merge 1 commit intofacebook:mainfrom
huntie:export-D101624433

Conversation

@huntie
Copy link
Copy Markdown
Member

@huntie huntie commented Apr 20, 2026

Summary:

Implements the Emulation.setEmulatedMedia CDP method in jsinspector-modern, scoped to prefers-color-scheme emulation. This allows CDP clients to toggle the app color scheme for debugging and visual verification.

Implementation notes

Adds a new EmulationAgent CDP domain agent that validates the features param, rejects unsupported media features/types, and delegates to HostTargetDelegate::onSetEmulatedMedia. Platform delegates:

  • Android: Calls AppCompatDelegate.setDefaultNightMode() on the UI thread via JNI through ReactHostImpl.
  • iOS: Sets overrideUserInterfaceStyle on the key UIWindow.

Both platforms trigger their existing Appearance change event propagation to JS automatically.

Changelog:
[General][Added] - React Native DevTools: Add support for light/dark mode emulation via Emulation.setEmulatedMedia

Reviewed By: hoxyq

Differential Revision: D101624433

@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 20, 2026
@meta-codesync
Copy link
Copy Markdown

meta-codesync Bot commented Apr 20, 2026

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

…book#56510)

Summary:

Implements the `Emulation.setEmulatedMedia` CDP method in `jsinspector-modern`, scoped to `prefers-color-scheme` emulation. This allows CDP clients to toggle the app color scheme for debugging and visual verification.

**Implementation notes**

Adds a new `EmulationAgent` CDP domain agent that validates the `features` param, rejects unsupported media features/types, and delegates to `HostTargetDelegate::onSetEmulatedMedia`. Platform delegates:

- **Android**: Calls `AppCompatDelegate.setDefaultNightMode()` on the UI thread via JNI through `ReactHostImpl`.
- **iOS**: Sets `overrideUserInterfaceStyle` on the key `UIWindow`.

Both platforms trigger their existing `Appearance` change event propagation to JS automatically.

Changelog:
[General][Added] - **React Native DevTools**: Add support for light/dark mode emulation via `Emulation.setEmulatedMedia`

Reviewed By: hoxyq

Differential Revision: D101624433
@meta-codesync meta-codesync Bot changed the title Support light/dark mode toggling via Emulation.setEmulatedMedia Support light/dark mode toggling via Emulation.setEmulatedMedia (#56510) Apr 21, 2026
@huntie huntie force-pushed the export-D101624433 branch from d3d28ed to c006b62 Compare April 21, 2026 12:06
@meta-codesync meta-codesync Bot closed this in 11a5432 Apr 21, 2026
@facebook-github-tools facebook-github-tools Bot added the Merged This PR has been merged. label Apr 21, 2026
@meta-codesync
Copy link
Copy Markdown

meta-codesync Bot commented Apr 21, 2026

This pull request has been merged in 11a5432.

@react-native-bot
Copy link
Copy Markdown
Collaborator

This pull request was successfully merged by @huntie in 11a5432

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

@huntie huntie deleted the export-D101624433 branch April 21, 2026 12:56
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