Skip to content

Commit fd243c4

Browse files
fix(mosaic): show connected account verification errors without animating on load
1 parent 2dbeeb5 commit fd243c4

3 files changed

Lines changed: 14 additions & 5 deletions

File tree

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
---
2+
---

‎packages/mosaic/src/components/section/section.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@ const SectionError = React.forwardRef<HTMLParagraphElement, SectionErrorProps>(f
308308
const element = React.useRef<HTMLElement | null>(null);
309309
const [messageElement, setMessageElement] = React.useState<HTMLElement | null>(null);
310310
const height = useMessageHeight(messageElement);
311-
const { mounted, transitionProps } = useTransition({ open, ref: element });
311+
const { mounted, transitionProps } = useTransition({ open, ref: element, animateOnMount: false });
312312
const message = useHeldMessage(children, open);
313313
const messageProps = stylex.props(reset.base, feedbackStyles.message, feedbackStyles.error);
314314

‎packages/mosaic/src/primitives/hooks/use-transition.ts‎

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
'use client';
22

3-
import { type CSSProperties, type RefObject, useEffect, useMemo } from 'react';
3+
import { type CSSProperties, type RefObject, useEffect, useMemo, useState } from 'react';
44

55
import { useAnimationsFinished } from './use-animations-finished';
66
import { type TransitionStatus, useTransitionStatus } from './use-transition-status';
77

88
export interface UseTransitionOptions {
99
open: boolean;
1010
ref: RefObject<HTMLElement | null>;
11+
animateOnMount?: boolean;
1112
}
1213

1314
export interface TransitionProps {
@@ -38,8 +39,12 @@ export interface UseTransitionReturn {
3839
* transitions (via `[data-starting-style]` / `[data-ending-style]`) and
3940
* CSS keyframe animations (via `[data-open]` / `[data-closed]`).
4041
*/
41-
export function useTransition({ open, ref }: UseTransitionOptions): UseTransitionReturn {
42+
export function useTransition({ open, ref, animateOnMount = true }: UseTransitionOptions): UseTransitionReturn {
4243
const { mounted, transitionStatus, setMounted } = useTransitionStatus(open);
44+
const [skipEnter, setSkipEnter] = useState(open && !animateOnMount);
45+
if (skipEnter && transitionStatus !== 'starting') {
46+
setSkipEnter(false);
47+
}
4348
const runOnAnimationsFinished = useAnimationsFinished(ref, open);
4449

4550
useEffect(() => {
@@ -62,13 +67,15 @@ export function useTransition({ open, ref }: UseTransitionOptions): UseTransitio
6267
props['data-closed'] = '';
6368
}
6469
if (transitionStatus === 'starting') {
65-
props['data-starting-style'] = '';
70+
if (!skipEnter) {
71+
props['data-starting-style'] = '';
72+
}
6673
props.style = { transition: 'none' };
6774
} else if (transitionStatus === 'ending') {
6875
props['data-ending-style'] = '';
6976
}
7077
return props;
71-
}, [open, mounted, transitionStatus]);
78+
}, [open, mounted, transitionStatus, skipEnter]);
7279

7380
return { mounted, transitionStatus, transitionProps };
7481
}

0 commit comments

Comments
 (0)