Skip to content

Commit e5927ff

Browse files
fix: bottom sheet not appearing with android reduce motion
1 parent 0a0a060 commit e5927ff

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 { Platform, StyleSheet } from 'react-native';
1112
import { State } from 'react-native-gesture-handler';
@@ -280,6 +281,13 @@ const BottomSheetComponent = forwardRef<BottomSheet, BottomSheetProps>(
280281
? userReduceMotionSetting
281282
: _providedOverrideReduceMotion === ReduceMotion.Always;
282283
}, [userReduceMotionSetting, _providedOverrideReduceMotion]);
284+
285+
const [, _forceUpdate] = useState(0);
286+
const handleReduceMotionMountFlush = useCallback(() => {
287+
if (Platform.OS === 'android' && reduceMotion) {
288+
_forceUpdate((prev: number) => prev + 1);
289+
}
290+
}, [reduceMotion]);
283291
//#endregion
284292

285293
//#region state/dynamic variables
@@ -971,7 +979,7 @@ const BottomSheetComponent = forwardRef<BottomSheet, BottomSheetProps>(
971979
* if animate on mount is set to true, then we animate to the propose position,
972980
* else, we set the position with out animation.
973981
*/
974-
if (animateOnMount) {
982+
if (animateOnMount && !(Platform.OS === 'android' && reduceMotion)) {
975983
animateToPosition(
976984
proposedPosition,
977985
ANIMATION_SOURCE.MOUNT,
@@ -981,6 +989,7 @@ const BottomSheetComponent = forwardRef<BottomSheet, BottomSheetProps>(
981989
} else {
982990
setToPosition(proposedPosition);
983991
isAnimatedOnMount.value = true;
992+
runOnJS(handleReduceMotionMountFlush)();
984993
}
985994
return;
986995
}
@@ -1071,6 +1080,7 @@ const BottomSheetComponent = forwardRef<BottomSheet, BottomSheetProps>(
10711080
isAnimatedOnMount,
10721081
isInTemporaryPosition,
10731082
isLayoutCalculated,
1083+
handleReduceMotionMountFlush,
10741084
]
10751085
);
10761086
//#endregion

0 commit comments

Comments
 (0)