Skip to content

Add contentSized to Android Modal (#60408) - #60408

Open
evankatz14 wants to merge 2 commits into
react:mainfrom
evankatz14:export-D126114637
Open

evankatz14 wants to merge 2 commits into
react:mainfrom
evankatz14:export-D126114637

Conversation

@evankatz14

@evankatz14 evankatz14 commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

Summary:

Add an opt-in contentSized prop to Android Modal.

RN normally measures modal content against the full parent size. With contentSized, Fabric and the JS wrapper measure the content instead, and the native window is sized to it and centered after layout. Outside presses are consumed by the dialog window, so they do not reach the parent.

Ordinary Modal keeps its existing window, layout, and animation theme selection.

Changelog:
[Android][Added] - Add contentSized prop to Modal to size the native window to its content.

Differential Revision: D126114637

@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 Nov 30, 2026
@meta-codesync

meta-codesync Bot commented Nov 30, 2026

Copy link
Copy Markdown

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

@github-actions

Copy link
Copy Markdown

Warning

JavaScript API change detected

This PR commits an update to ReactNativeApi.d.ts, indicating a change to React Native's public JavaScript API.

  • Please include a clear changelog message.
  • This change will be subject to additional review.

This change was flagged as: POTENTIALLY_BREAKING

evankatz14 added a commit to evankatz14/react-native that referenced this pull request Nov 30, 2026
Summary:
Pull Request resolved: react#60408

Add an opt-in `contentSized` prop to Android `Modal`.

RN normally measures modal content against the full parent size. With `contentSized`, Fabric and the JS wrapper measure the content instead, and the native window is sized to it and centered after layout. Outside presses are consumed by the dialog window, so they do not reach the parent.

Ordinary `Modal` keeps its existing window, layout, and animation theme selection.

Changelog:
[Android][Added] - Add `contentSized` prop to `Modal` to size the native window to its content.

Differential Revision: D126114637
@meta-codesync meta-codesync Bot changed the title Add contentSized to Android Modal Add contentSized to Android Modal (#60408) Nov 30, 2026
evankatz14 added a commit to evankatz14/react-native that referenced this pull request Dec 1, 2026
Summary:
Pull Request resolved: react#60408

Add an opt-in `contentSized` prop to Android `Modal`.

RN normally measures modal content against the full parent size. With `contentSized`, Fabric and the JS wrapper measure the content instead, and the native window is sized to it and centered after layout. Outside presses are consumed by the dialog window, so they do not reach the parent.

Ordinary `Modal` keeps its existing window, layout, and animation theme selection.

Changelog:
[Android][Added] - Add `contentSized` prop to `Modal` to size the native window to its content.

Differential Revision: D126114637
Summary:
Pull Request resolved: react#60388

Add the Android-only `Modal.dimAmount` prop to control system dimming behind a non-transparent modal. The native value is clamped to `0–1` and defaults to `0.5` when omitted or reset. `transparent={true}` still disables system dimming and keeps the container transparent.

On Android, explicitly setting `dimAmount` makes the JS container transparent unless an explicit `backdropColor` is provided. With `dimAmount` omitted, existing background behavior is unchanged: `transparent` takes precedence, then `backdropColor`, then `style.backgroundColor` or the white default. An explicit `dimAmount` also takes precedence over `style.backgroundColor` when neither `transparent` nor `backdropColor` is set.

Deprecate `Modal.backdropColor` in the public prop types without changing its behavior. Prefer `style={{backgroundColor: ...}}` for custom container colors, except when combining a custom color with an explicit Android `dimAmount`: that combination still needs `backdropColor` in this version.

Replace the duplicate Android dim-flag mask with the equivalent `addFlags(FLAG_DIM_BEHIND)` call. Update the Android, C++, and JavaScript API snapshots, and cover prop forwarding and reset, transparent container defaults, and explicit `backdropColor` precedence in the Modal integration tests.

Changelog:
[Android][Added] - Add `Modal.dimAmount` to configure system dimming behind non-transparent modals.
[General][Deprecated] - Deprecate `Modal.backdropColor` without removing it.

Reviewed By: Abbondanzo

Differential Revision: D125038408
Summary:
Pull Request resolved: react#60408

Add an opt-in `contentSized` prop to Android `Modal`.

RN normally measures modal content against the full parent size. With `contentSized`, Fabric and the JS wrapper measure the content instead, and the native window is sized to it and centered after layout. Outside presses are consumed by the dialog window, so they do not reach the parent.

Ordinary `Modal` keeps its existing window, layout, and animation theme selection.

Changelog:
[Android][Added] - Add `contentSized` prop to `Modal` to size the native window to its content.

Differential Revision: D126114637
evankatz14 added a commit to evankatz14/react-native that referenced this pull request Dec 1, 2026
Summary:
Pull Request resolved: react#60408

Add an opt-in `contentSized` prop to Android `Modal`.

RN normally measures modal content against the full parent size. With `contentSized`, Fabric and the JS wrapper measure the content instead, and the native window is sized to it and centered after layout. Outside presses are consumed by the dialog window, so they do not reach the parent.

Ordinary `Modal` keeps its existing window, layout, and animation theme selection.

Changelog:
[Android][Added] - Add `contentSized` prop to `Modal` to size the native window to its content.

Differential Revision: D126114637

This branch has not been deployed

No deployments
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. meta-exported p: Facebook Partner: Facebook Partner

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant