Skip to content

Commit ddd8af3

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

5 files changed

Lines changed: 10133 additions & 7217 deletions

File tree

.yarn/install-state.gz

947 KB
Binary file not shown.

.yarnrc.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
nodeLinker: node-modules

package.json

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,13 +70,13 @@
7070
"react": "*",
7171
"react-native": "*",
7272
"react-native-gesture-handler": ">=2.16.1",
73-
"react-native-reanimated": ">=3.16.0 || >=4.0.0-"
73+
"react-native-reanimated": "*"
7474
},
7575
"peerDependenciesMeta": {
76-
"@types/react-native": {
76+
"@types/react": {
7777
"optional": true
7878
},
79-
"@types/react": {
79+
"@types/react-native": {
8080
"optional": true
8181
}
8282
},
@@ -94,5 +94,6 @@
9494
},
9595
"overrides": {
9696
"conventional-changelog-conventionalcommits": "8.0.0"
97-
}
97+
},
98+
"packageManager": "yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e"
9899
}

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 && !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)