Skip to content

Commit 941f22f

Browse files
fix(mobile): scroll to end jumps instead of glides when Reduce Motion is on
The thread's Scroll to end button and the scroll to a just-sent message now move instantly when iOS or Android asks for reduced motion. The setting is tracked with an accessibility listener, so changing it while a thread is open applies to the next scroll. Normal motion is unchanged. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
1 parent a1d9d72 commit 941f22f

1 file changed

Lines changed: 22 additions & 4 deletions

File tree

‎apps/mobile/src/features/threads/ThreadDetailScreen.tsx‎

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ import {
5454
useState,
5555
} from "react";
5656
import {
57+
AccessibilityInfo,
5758
Alert,
5859
AppState,
5960
Keyboard,
@@ -679,6 +680,18 @@ export const ThreadDetailScreen = memo(function ThreadDetailScreen(props: Thread
679680
[userInputCoverageApplies],
680681
);
681682
const { freeze, scrollMessageToEnd } = useKeyboardScrollToEnd({ listRef });
683+
// Read when a scroll starts; the listener keeps it current if the user
684+
// changes Reduce Motion while the thread is open.
685+
const reduceMotionRef = useRef(true);
686+
useEffect(() => {
687+
void AccessibilityInfo.isReduceMotionEnabled().then((enabled) => {
688+
reduceMotionRef.current = enabled;
689+
});
690+
const subscription = AccessibilityInfo.addEventListener("reduceMotionChanged", (enabled) => {
691+
reduceMotionRef.current = enabled;
692+
});
693+
return () => subscription.remove();
694+
}, []);
682695
const endFollowEnabledRef = useRef(true);
683696
endFollowEnabledRef.current = endFollowEnabled;
684697
const overlayRepinTimerRef = useRef<ReturnType<typeof setTimeout> | null>(null);
@@ -906,7 +919,10 @@ export const ThreadDetailScreen = memo(function ThreadDetailScreen(props: Thread
906919
) {
907920
return;
908921
}
909-
return scrollMessageToEnd({ animated: true, closeKeyboard: false });
922+
return scrollMessageToEnd({
923+
animated: !reduceMotionRef.current,
924+
closeKeyboard: false,
925+
});
910926
})
911927
.catch(() => {
912928
if (
@@ -1007,9 +1023,11 @@ export const ThreadDetailScreen = memo(function ThreadDetailScreen(props: Thread
10071023

10081024
const handleScrollToEnd = useCallback(() => {
10091025
void Haptics.selectionAsync();
1010-
void scrollMessageToEnd({ animated: true, closeKeyboard: false }).catch(() => {
1011-
freeze.set(false);
1012-
});
1026+
void scrollMessageToEnd({ animated: !reduceMotionRef.current, closeKeyboard: false }).catch(
1027+
() => {
1028+
freeze.set(false);
1029+
},
1030+
);
10131031
}, [freeze, scrollMessageToEnd]);
10141032

10151033
const showScrollToEndButton = contentPresentationKind === "ready" && !endFollowEnabled;

0 commit comments

Comments
 (0)