Skip to content

fix: forward style prop to Modal inner container View#56181

Open
AnuMessi10 wants to merge 1 commit intofacebook:mainfrom
AnuMessi10:fix/modal-style-prop-forwarding
Open

fix: forward style prop to Modal inner container View#56181
AnuMessi10 wants to merge 1 commit intofacebook:mainfrom
AnuMessi10:fix/modal-style-prop-forwarding

Conversation

@AnuMessi10
Copy link

@AnuMessi10 AnuMessi10 commented Mar 21, 2026

Summary:

Modal accepts a style prop via ViewProps (since ModalProps spreads ...ViewProps) but silently discards it. The inner container <View> only applies styles.container and containerStyles (which handles backdropColor/transparent), so any style passed by the consumer has no effect.

For example, <Modal style={{ padding: 20 }}> compiles without errors but the padding is never applied.

This forwards this.props.style as the last element in the inner container's style array, so consumer styles are applied with correct precedence (defaults → backdrop → consumer).

Changelog:

[GENERAL] [FIXED] - Forward style prop to Modal's inner container View so consumer styles are applied

Test Plan:

  1. Render a Modal with a custom style prop:

    <Modal visible style={{ padding: 40, backgroundColor: 'red' }}>
      <View style={{ flex: 1, backgroundColor: 'white' }}>
        <Text>Hello</Text>
      </View>
    </Modal>
  2. Before fix: padding and backgroundColor are silently ignored

  3. After fix: The modal container has 40px padding and a red background

Also verified that:

  • backdropColor prop still works (overridden by style.backgroundColor if both are set, which is expected)
  • transparent={true} still produces a transparent background when no style override is passed
  • Default behavior (no style prop) is unchanged

Modal accepts `style` via ViewProps but silently discards it.
The inner container View only applies `styles.container` and
`containerStyles` (which handles `backdropColor`/`transparent`),
ignoring any style prop passed by the consumer.

This means `<Modal style={{ padding: 20 }}>` has no effect even
though the types allow it.

Forward `this.props.style` as the last element in the style array
so consumer styles are applied and can override defaults.
@meta-cla
Copy link

meta-cla bot commented Mar 21, 2026

Hi @AnuMessi10!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks!

@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 21, 2026
@meta-cla
Copy link

meta-cla bot commented Mar 21, 2026

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks!

@facebook-github-tools facebook-github-tools 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 21, 2026
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.

1 participant