Skip to content

Commit 6daebdb

Browse files
fix(mobile): keep reduced-motion views visible and aligned (#23230)
Co-authored-by: maria-rcks <[email protected]>
1 parent b8ca826 commit 6daebdb

2 files changed

Lines changed: 10 additions & 6 deletions

File tree

‎apps/mobile/src/components/ComposerToolbar.tsx‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import {
1212
type ViewStyle,
1313
} from "react-native";
1414

15-
import Animated, { FadeIn } from "react-native-reanimated";
15+
import Animated, { FadeIn, useReducedMotion } from "react-native-reanimated";
1616

1717
import { cn } from "../lib/cn";
1818
import { AppText as Text } from "./ui/AppText";
@@ -43,6 +43,7 @@ export function ComposerInlineControl(props: {
4343
readonly showChevron?: boolean;
4444
}) {
4545
const { scale, smallIconSize } = useAndroidControlSizing();
46+
const reducedMotion = useReducedMotion();
4647
// Keep the picker anchored to its parent while the editor changes height.
4748
const animatesLabel = props.iconOnly !== undefined;
4849
const iconSize = props.size === "large" ? 20 : smallIconSize;
@@ -85,7 +86,7 @@ export function ComposerInlineControl(props: {
8586
{props.iconOnly ? null : (
8687
<Animated.View
8788
className="shrink"
88-
entering={animatesLabel ? INLINE_CONTROL_LABEL_ENTERING : undefined}
89+
entering={animatesLabel && !reducedMotion ? INLINE_CONTROL_LABEL_ENTERING : undefined}
8990
>
9091
<Text
9192
className={cn(

‎apps/mobile/src/features/threads/floating-working-control.tsx‎

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import Animated, {
1616
ReduceMotion,
1717
type SharedValue,
1818
useAnimatedStyle,
19+
useReducedMotion,
1920
useSharedValue,
2021
withTiming,
2122
} from "react-native-reanimated";
@@ -79,6 +80,7 @@ export function FloatingWorkingControl(props: {
7980
readonly lift?: SharedValue<number>;
8081
}) {
8182
const { width: windowWidth } = useWindowDimensions();
83+
const reducedMotion = useReducedMotion();
8284
const [overlayWidth, setOverlayWidth] = useState(windowWidth);
8385
const [queueWidth, setQueueWidth] = useState(0);
8486
const [actionWidth, setActionWidth] = useState(0);
@@ -271,8 +273,8 @@ export function FloatingWorkingControl(props: {
271273
className="absolute left-0 right-0 z-20 items-center"
272274
style={[{ top: -CONTROL_OVERLAY_OFFSET }, liftStyle]}
273275
onLayout={(event) => setOverlayWidth(event.nativeEvent.layout.width)}
274-
entering={NATIVE_LIQUID_GLASS_SUPPORTED ? undefined : CONTROL_ENTERING}
275-
exiting={NATIVE_LIQUID_GLASS_SUPPORTED ? undefined : CONTROL_EXITING}
276+
entering={NATIVE_LIQUID_GLASS_SUPPORTED || reducedMotion ? undefined : CONTROL_ENTERING}
277+
exiting={NATIVE_LIQUID_GLASS_SUPPORTED || reducedMotion ? undefined : CONTROL_EXITING}
276278
>
277279
{hasCapsule && NATIVE_LIQUID_GLASS_SUPPORTED ? (
278280
<UniwindGlassContainer
@@ -551,12 +553,13 @@ function StatusLabelRow(props: {
551553
readonly onLayout: (event: LayoutChangeEvent) => void;
552554
readonly onPress?: () => void;
553555
}) {
556+
const reducedMotion = useReducedMotion();
554557
const rowClassName = `h-11 flex-row items-center px-4 ${props.className ?? ""}`;
555558
return (
556559
<Animated.View
557560
className="absolute max-w-full"
558-
entering={LABEL_ENTERING}
559-
exiting={LABEL_EXITING}
561+
entering={reducedMotion ? undefined : LABEL_ENTERING}
562+
exiting={reducedMotion ? undefined : LABEL_EXITING}
560563
onLayout={props.onLayout}
561564
>
562565
{props.onPress ? (

0 commit comments

Comments
 (0)