-
-
Notifications
You must be signed in to change notification settings - Fork 783
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[v4] | Footer height not included in dynamic size with scroll view #1725
Comments
@smikheiev: hello! 👋 This issue is being automatically closed because it does not follow the issue template. |
I have a temporary solution Steps to fix the issue
diff --git a/node_modules/@gorhom/bottom-sheet/src/components/bottomSheetScrollable/createBottomSheetScrollableComponent.tsx b/node_modules/@gorhom/bottom-sheet/src/components/bottomSheetScrollable/createBottomSheetScrollableComponent.tsx
index 9162b66..52bd563 100644
--- a/node_modules/@gorhom/bottom-sheet/src/components/bottomSheetScrollable/createBottomSheetScrollableComponent.tsx
+++ b/node_modules/@gorhom/bottom-sheet/src/components/bottomSheetScrollable/createBottomSheetScrollableComponent.tsx
@@ -4,7 +4,7 @@ import React, {
useImperativeHandle,
useMemo,
} from 'react';
-import { useAnimatedProps, useAnimatedStyle } from 'react-native-reanimated';
+import { useAnimatedProps, useAnimatedReaction, useAnimatedStyle } from 'react-native-reanimated';
import { Gesture } from 'react-native-gesture-handler';
import { BottomSheetDraggableContext } from '../../contexts/gesture';
import {
@@ -87,11 +87,17 @@ export function createBottomSheetScrollableComponent<T, P>(
);
//#endregion
+ useAnimatedReaction(() => {
+ return animatedFooterHeight.value
+ }, (curr, prev) => {
+ animatedContentHeight.value += curr - (prev || 0);
+ })
+
//#region callbacks
const handleContentSizeChange = useStableCallback(
(contentWidth: number, contentHeight: number) => {
if (enableDynamicSizing) {
- animatedContentHeight.value = contentHeight;
+ animatedContentHeight.value = contentHeight + animatedFooterHeight.value;
}
if (onContentSizeChange) {
Warning This solution might not work if your footer changes layout on state update, in my case it was static so this solution did the trick. |
I also notice this. So if you use flat list fore example, some of the element would be behind the footer, instead of the sheet grow bigger. |
this should be fixed on the next release |
Unfortunally don't work without this:
"@gorhom/bottom-sheet": "^5.0.0-alpha.7", |
In my case also with latest 4.6.1 the footer height are still not being included. Do i need to wrap my footer with BottomSheetFooter? Or any flag to offset the height? |
Same on |
Yeap, I knew about the flag, but the flag does nothing, played around with the source code for a while and nothing fix it except adding the useAnimatedReaction, works for maxDynamicContentSize perfectly too. Will do more testing on it |
Upgraded to 4.6.1 & still having this issue too. |
@gorhom I wonder, why diff --git a/node_modules/@gorhom/bottom-sheet/src/components/bottomSheet/BottomSheet.tsx b/node_modules/@gorhom/bottom-sheet/src/components/bottomSheet/BottomSheet.tsx
index f20e3dc..021c1f8 100644
--- a/node_modules/@gorhom/bottom-sheet/src/components/bottomSheet/BottomSheet.tsx
+++ b/node_modules/@gorhom/bottom-sheet/src/components/bottomSheet/BottomSheet.tsx
@@ -204,6 +204,7 @@ const BottomSheetComponent = forwardRef<BottomSheet, BottomSheetProps>(
animatedContainerHeight,
animatedContentHeight,
animatedHandleHeight,
+ animatedFooterHeight,
enableDynamicSizing,
maxDynamicContentSize
);
diff --git a/node_modules/@gorhom/bottom-sheet/src/hooks/useNormalizedSnapPoints.ts b/node_modules/@gorhom/bottom-sheet/src/hooks/useNormalizedSnapPoints.ts
index 872b2f8..65d23e0 100644
--- a/node_modules/@gorhom/bottom-sheet/src/hooks/useNormalizedSnapPoints.ts
+++ b/node_modules/@gorhom/bottom-sheet/src/hooks/useNormalizedSnapPoints.ts
@@ -14,6 +14,7 @@ import {
* @param containerHeight BottomSheetContainer height.
* @param contentHeight content size.
* @param handleHeight handle size.
+ * @param footerHeight footer size.
* @param enableDynamicSizing
* @param maxDynamicContentSize
* @returns {Animated.SharedValue<number[]>}
@@ -23,6 +24,7 @@ export const useNormalizedSnapPoints = (
containerHeight: Animated.SharedValue<number>,
contentHeight: Animated.SharedValue<number>,
handleHeight: Animated.SharedValue<number>,
+ footerHeight: Animated.SharedValue<number>,
enableDynamicSizing: BottomSheetProps['enableDynamicSizing'],
maxDynamicContentSize: BottomSheetProps['maxDynamicContentSize']
) => {
@@ -56,7 +58,7 @@ export const useNormalizedSnapPoints = (
_normalizedSnapPoints.push(
containerHeight.value -
Math.min(
- contentHeight.value + handleHeight.value,
+ contentHeight.value + handleHeight.value + footerHeight.value,
maxDynamicContentSize !== undefined
? maxDynamicContentSize
: containerHeight.value |
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
Steps To Reproduce
footerComponent={Footer}
and without it (remove or comment it out)with-footer.mp4
without-footer.mp4
Reproducible sample code
The text was updated successfully, but these errors were encountered: