Skip to content

Commit dc0ebfd

Browse files
docs: clarify Toast layout remeasure behavior
Document why entrance animation runs once while dismiss targets resync after text layout changes toast height. Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent 370405f commit dc0ebfd

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

  • app/component-library/components/Toast

app/component-library/components/Toast/Toast.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,10 @@ const Toast = forwardRef((_, ref: React.ForwardedRef<ToastRef>) => {
303303
closeToast,
304304
}));
305305

306+
// Toast height can change after the first render when text layout updates
307+
// top-alignment styles. We avoid restarting the entrance animation and update
308+
// the dismiss position after the final size is measured to keep animation and
309+
// auto-dismiss timing consistent.
306310
const onAnimatedViewLayout = (e: LayoutChangeEvent) => {
307311
if (toastOptions) {
308312
const { height } = e.nativeEvent.layout;
@@ -311,9 +315,6 @@ const Toast = forwardRef((_, ref: React.ForwardedRef<ToastRef>) => {
311315

312316
hiddenTranslateY.value = nextHiddenTranslateY;
313317

314-
// Text layout can change top-alignment styles and trigger another layout
315-
// pass. Only run the entrance animation on the first layout, but keep
316-
// dismiss targets in sync with the latest measured height.
317318
if (animationStartedRef.current) {
318319
syncDismissTargetAfterRemeasure();
319320
return;

0 commit comments

Comments
 (0)