Skip to content

fix: recalculate toast height when type or promise state changes - #774

Open
q121212 wants to merge 1 commit into
emilkowalski:mainfrom
q121212:fix/toast-height-update-on-replace
Open

fix: recalculate toast height when type or promise state changes#774
q121212 wants to merge 1 commit into
emilkowalski:mainfrom
q121212:fix/toast-height-update-on-replace

Conversation

@q121212

@q121212 q121212 commented Jul 11, 2026

Copy link
Copy Markdown

Fixes #719

Problem

When a toast is replaced with another toast of the same ID but different height (e.g. shorter text → longer text, or promise toast loading → success), the layout doesn't recalculate. This causes visual clipping, overlap, or excessive space.

Root Cause

The useLayoutEffect that measures and reports toast height was missing toast.type and toast.promise from its dependency array. When a promise toast transitions from loading to success, the icon changes from spinner to checkmark (potentially different height), but the effect never re-fires.

Fix

Added toast.type and toast.promise to the dependency array so height measurement runs whenever the toast type or promise state changes.

The height measurement effect was missing toast.type and
toast.promise from its dependency array. When a promise toast
transitions from loading to success (icon changes from spinner
to checkmark) or when a toast is replaced with content of a
different height, the layout was not recalculated.

Fixes emilkowalski#719
@vercel

vercel Bot commented Jul 11, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
sonner Error Error Jul 11, 2026 2:34pm

Request Review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: Replacing a shorter toast with a longer toast of the same toast ID will result in rendering bugs (size allotted to the toast does not change)

1 participant