fix: forward style prop to Modal inner container View#56181
fix: forward style prop to Modal inner container View#56181AnuMessi10 wants to merge 1 commit intofacebook:mainfrom
Conversation
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.
|
Hi @AnuMessi10! Thank you for your pull request and welcome to our community. Action RequiredIn 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. ProcessIn 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 If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks! |
|
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks! |
Summary:
Modalaccepts astyleprop viaViewProps(sinceModalPropsspreads...ViewProps) but silently discards it. The inner container<View>only appliesstyles.containerandcontainerStyles(which handlesbackdropColor/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.styleas 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
styleprop to Modal's inner container View so consumer styles are appliedTest Plan:
Render a Modal with a custom style prop:
Before fix:
paddingandbackgroundColorare silently ignoredAfter fix: The modal container has 40px padding and a red background
Also verified that:
backdropColorprop still works (overridden bystyle.backgroundColorif both are set, which is expected)transparent={true}still produces a transparent background when nostyleoverride is passedstyleprop) is unchanged