Skip to content

Commit 44a5bca

Browse files
coolsoftwaretylergorhom
authored andcommitted
fix: bottom sheet not appearing with android reduce motion
1 parent 8964c06 commit 44a5bca

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

src/components/bottomSheet/BottomSheet.tsx

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import React, {
66
useEffect,
77
useImperativeHandle,
88
useMemo,
9+
useState,
910
} from 'react';
1011
import { Dimensions, Platform, StyleSheet } from 'react-native';
1112
import { State } from 'react-native-gesture-handler';
@@ -279,6 +280,13 @@ const BottomSheetComponent = forwardRef<BottomSheet, BottomSheetProps>(
279280
? userReduceMotionSetting
280281
: _providedOverrideReduceMotion === ReduceMotion.Always;
281282
}, [userReduceMotionSetting, _providedOverrideReduceMotion]);
283+
284+
const [, _forceUpdate] = useState(0);
285+
const handleReduceMotionMountFlush = useCallback(() => {
286+
if (Platform.OS === 'android' && reduceMotion) {
287+
_forceUpdate((prev: number) => prev + 1);
288+
}
289+
}, [reduceMotion]);
282290
//#endregion
283291

284292
//#region state/dynamic variables
@@ -977,7 +985,7 @@ const BottomSheetComponent = forwardRef<BottomSheet, BottomSheetProps>(
977985
* if animate on mount is set to true, then we animate to the propose position,
978986
* else, we set the position with out animation.
979987
*/
980-
if (animateOnMount) {
988+
if (animateOnMount && !(Platform.OS === 'android' && reduceMotion)) {
981989
animateToPosition(
982990
proposedPosition,
983991
ANIMATION_SOURCE.MOUNT,
@@ -987,6 +995,7 @@ const BottomSheetComponent = forwardRef<BottomSheet, BottomSheetProps>(
987995
} else {
988996
setToPosition(proposedPosition);
989997
didAnimateOnMount.value = true;
998+
runOnJS(handleReduceMotionMountFlush)();
990999
}
9911000
return;
9921001
}
@@ -1077,6 +1086,7 @@ const BottomSheetComponent = forwardRef<BottomSheet, BottomSheetProps>(
10771086
didAnimateOnMount,
10781087
isInTemporaryPosition,
10791088
isLayoutCalculated,
1089+
handleReduceMotionMountFlush,
10801090
]
10811091
);
10821092
//#endregion

0 commit comments

Comments
 (0)