fix: apply every entry of a content container style array - #2748
Open
bradreelee wants to merge 1 commit into
Open
fix: apply every entry of a content container style array#2748bradreelee wants to merge 1 commit into
bradreelee wants to merge 1 commit into
Conversation
`useBottomSheetContentContainerStyle` folded array styles with `StyleSheet.compose(..._style)`, but `composeStyles(style1, style2)` accepts exactly two arguments and silently drops the rest. Any array of three or more entries passed to `BottomSheetView`'s `style` or a scrollable's `contentContainerStyle` lost everything from the third entry on, with no error or warning. The same call is also why the name is misleading: `compose` returns `[a, b]` rather than a merged object, so the `enableFooterMarginAdjustment` branch below destructures `paddingBottom` / `padding` / `paddingVertical` off an array and always reads `undefined`. The caller's bottom padding is then replaced by `0 + footerHeight`. `StyleSheet.flatten` handles arrays of any length and depth and returns a real object, which fixes both and lets the `@ts-ignore` go. Closes gorhom#2383
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
Closes #2383, which was reported in July 2025 with a correct diagnosis and then auto-closed by the stale bot without a fix. It still reproduces on
5.2.14.useBottomSheetContentContainerStylefolds array styles with:composeStyles(style1, style2)accepts exactly two arguments, so every entry from the third on is silently discarded — no error, no warning, and the// @ts-ignoreon that line is what kept the arity mismatch quiet. Anything passed as a 3+ entry array toBottomSheetView'sstyleor a scrollable'scontentContainerStylenever reaches the view.This bit us in production on Android. A sheet with
enableContentPanningGesture={false}needs a background colour on the content wrapper (otherwise taps leak through to the backdrop), which makes the natural style array three entries long:The bottom safe-area padding disappeared and the sheet's primary button rendered underneath the Android navigation bar. Because the value was computed correctly and the style object looked right in the source, this was expensive to track down — nothing points at the library.
There is a second, related bug in the same call.
composereturns[a, b], not a merged object, so theenableFooterMarginAdjustmentbranch immediately below destructures off an array:currentBottomPaddingtherefore stays0, and the caller's bottom padding is replaced by0 + footerHeightwhenever an array is passed.StyleSheet.flattenhandles arrays of any length and depth and returns a real object, fixing both and letting the@ts-ignorego.Verification
yarn typescriptandyarn lintpass (the one remaining biome warning is pre-existing, inuseBoundingClientRect.ts).The repo has no test runner, so I verified against React Native's real
composeStylesandflattenStylerather than stand-ins — running the exact expression the hook uses, before and after:Case 3 explains why this went unnoticed for so long: two-entry arrays, the overwhelmingly common case, behave identically before and after.
Happy to add the repro as a test if you'd like to set up a runner, or to port it to the example app instead.