Skip to content
TypeScript

fix(mobile): keep reduced-motion views visible and aligned (#23230)

Alex6daebdb67194
diff --git a/apps/mobile/src/components/ComposerToolbar.tsx b/apps/mobile/src/components/ComposerToolbar.tsx
index 8963a4039d5..75e167fae66 100644
--- a/apps/mobile/src/components/ComposerToolbar.tsx
+++ b/apps/mobile/src/components/ComposerToolbar.tsx
@@ -12,7 +12,7 @@ import {
type ViewStyle,
} from "react-native";
-import Animated, { FadeIn } from "react-native-reanimated";
+import Animated, { FadeIn, useReducedMotion } from "react-native-reanimated";
import { cn } from "../lib/cn";
import { AppText as Text } from "./ui/AppText";
@@ -43,6 +43,7 @@ export function ComposerInlineControl(props: {
readonly showChevron?: boolean;
}) {
const { scale, smallIconSize } = useAndroidControlSizing();
+ const reducedMotion = useReducedMotion();
// Keep the picker anchored to its parent while the editor changes height.
const animatesLabel = props.iconOnly !== undefined;
const iconSize = props.size === "large" ? 20 : smallIconSize;
@@ -85,7 +86,7 @@ export function ComposerInlineControl(props: {
{props.iconOnly ? null : (
<Animated.View
className="shrink"
- entering={animatesLabel ? INLINE_CONTROL_LABEL_ENTERING : undefined}
+ entering={animatesLabel && !reducedMotion ? INLINE_CONTROL_LABEL_ENTERING : undefined}
>
<Text
className={cn(
diff --git a/apps/mobile/src/features/threads/floating-working-control.tsx b/apps/mobile/src/features/threads/floating-working-control.tsx
index c1440535e9c..1dc95a85b2d 100644
--- a/apps/mobile/src/features/threads/floating-working-control.tsx
+++ b/apps/mobile/src/features/threads/floating-working-control.tsx
@@ -16,6 +16,7 @@ import Animated, {
ReduceMotion,
type SharedValue,
useAnimatedStyle,
+ useReducedMotion,
useSharedValue,
withTiming,
} from "react-native-reanimated";
@@ -79,6 +80,7 @@ export function FloatingWorkingControl(props: {
readonly lift?: SharedValue<number>;
}) {
const { width: windowWidth } = useWindowDimensions();
+ const reducedMotion = useReducedMotion();
const [overlayWidth, setOverlayWidth] = useState(windowWidth);
const [queueWidth, setQueueWidth] = useState(0);
const [actionWidth, setActionWidth] = useState(0);
@@ -271,8 +273,8 @@ export function FloatingWorkingControl(props: {
className="absolute left-0 right-0 z-20 items-center"
style={[{ top: -CONTROL_OVERLAY_OFFSET }, liftStyle]}
onLayout={(event) => setOverlayWidth(event.nativeEvent.layout.width)}
- entering={NATIVE_LIQUID_GLASS_SUPPORTED ? undefined : CONTROL_ENTERING}
- exiting={NATIVE_LIQUID_GLASS_SUPPORTED ? undefined : CONTROL_EXITING}
+ entering={NATIVE_LIQUID_GLASS_SUPPORTED || reducedMotion ? undefined : CONTROL_ENTERING}
+ exiting={NATIVE_LIQUID_GLASS_SUPPORTED || reducedMotion ? undefined : CONTROL_EXITING}
>
{hasCapsule && NATIVE_LIQUID_GLASS_SUPPORTED ? (
<UniwindGlassContainer
@@ -551,12 +553,13 @@ function StatusLabelRow(props: {
readonly onLayout: (event: LayoutChangeEvent) => void;
readonly onPress?: () => void;
}) {
+ const reducedMotion = useReducedMotion();
const rowClassName = `h-11 flex-row items-center px-4 ${props.className ?? ""}`;
return (
<Animated.View
className="absolute max-w-full"
- entering={LABEL_ENTERING}
- exiting={LABEL_EXITING}
+ entering={reducedMotion ? undefined : LABEL_ENTERING}
+ exiting={reducedMotion ? undefined : LABEL_EXITING}
onLayout={props.onLayout}
>
{props.onPress ? (