TypeScript
fix(mobile): scroll to end jumps instead of glides when Reduce Motion is on (#16015)
Alex Southwelld6cd7b334e72
diff --git a/apps/mobile/src/features/threads/ThreadDetailScreen.tsx b/apps/mobile/src/features/threads/ThreadDetailScreen.tsxindex a456387a31c..bb36fce9bcb 100644--- a/apps/mobile/src/features/threads/ThreadDetailScreen.tsx+++ b/apps/mobile/src/features/threads/ThreadDetailScreen.tsx@@ -81,6 +81,7 @@ import Animated, {useAnimatedReaction,useAnimatedStyle,useDerivedValue,+ useReducedMotion,useSharedValue,withTiming,} from "react-native-reanimated";@@ -726,6 +727,7 @@ export const ThreadDetailScreen = function ThreadDetailScreen(props: ThreadDetai[userInputCoverageApplies],);const { freeze, scrollMessageToEnd } = useKeyboardScrollToEnd({ listRef });+ const reduceMotion = useReducedMotion();// Repin timers fire after the render that scheduled them, so they read follow// state from the ref the writers below keep in step with it.const endFollowEnabledRef = useRef(true);@@ -895,7 +897,10 @@ export const ThreadDetailScreen = function ThreadDetailScreen(props: ThreadDetai) {return;}- return scrollMessageToEnd({ animated: true, closeKeyboard: false });+ return scrollMessageToEnd({+ animated: !reduceMotion,+ closeKeyboard: false,+ });}).catch(() => {if (@@ -916,6 +921,7 @@ export const ThreadDetailScreen = function ThreadDetailScreen(props: ThreadDetaicontentPresentationKind,props.queuedMessages,selectedThreadFeed,+ reduceMotion,scrollMessageToEnd,selectedThreadKey,]);@@ -981,7 +987,7 @@ export const ThreadDetailScreen = function ThreadDetailScreen(props: ThreadDetaiconst handleScrollToEnd = () => {void Haptics.selectionAsync();- void scrollMessageToEnd({ animated: true, closeKeyboard: false }).catch(() => {+ void scrollMessageToEnd({ animated: !reduceMotion, closeKeyboard: false }).catch(() => {freeze.set(false);});};