-
-
Notifications
You must be signed in to change notification settings - Fork 873
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
Bug
I have a bottom sheet with a scroll view inside, and with the enableDynamicSizing
prop set. Dynamic size calculation seems to work fine - the bottom sheet height is adjusted to the scroll view content height.
But when I add a footer with footerComponent
prop, the bottom sheet height is not changed. Footer adds a bottom margin so the content can be scrolled above it, but doesn't change the bottom sheet height.
I'm not sure if this is an expected behavior or not. If it is - is there a way to include footer height in the bottom sheet dynamic height calculation?
Environment info
Library | Version |
---|---|
@gorhom/bottom-sheet | 4.6.0 |
react-native | 0.71.15 |
react-native-reanimated | 3.6.1 |
react-native-gesture-handler | 2.9.0 |
Steps To Reproduce
- Try to run the code below with
footerComponent={Footer}
and without it (remove or comment it out) - See that the bottom sheet height doesn't change
with footer | without footer |
---|---|
with-footer.mp4 |
without-footer.mp4 |
Reproducible sample code
const App = () => {
const sheetRef = useRef<BottomSheet>(null)
const data = useMemo(
() =>
Array(15)
.fill(0)
.map((_, index) => `index-${index}`),
[]
)
const handleOpenPress = useCallback(() => {
sheetRef.current?.expand()
}, [])
const handleClosePress = useCallback(() => {
sheetRef.current?.close()
}, [])
const renderItem = useCallback(
(item) => (
<View key={item} style={styles.itemContainer}>
<Text>{item}</Text>
</View>
),
[]
)
return (
<View style={styles.container}>
<Button title="Open" onPress={handleOpenPress} />
<Button title="Close" onPress={handleClosePress} />
<BottomSheet
//
enableDynamicSizing
enablePanDownToClose
footerComponent={Footer}
ref={sheetRef}
>
<BottomSheetScrollView enableFooterMarginAdjustment>{data.map(renderItem)}</BottomSheetScrollView>
</BottomSheet>
</View>
)
}
const Footer = ({ animatedFooterPosition }: BottomSheetFooterProps) => {
return (
<BottomSheetFooter animatedFooterPosition={animatedFooterPosition}>
<View style={styles.footer}>
<Text>Some footer</Text>
</View>
</BottomSheetFooter>
)
}
const styles = StyleSheet.create({
container: {
flex: 1,
},
itemContainer: {
padding: 6,
margin: 6,
backgroundColor: '#eee',
},
footer: {
backgroundColor: 'pink',
height: 60,
justifyContent: 'center',
alignItems: 'center',
},
})
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working