Skip to content

Stabilize visible toast layout offsets to prevent hover flicker#702

Merged
juliusmarminge merged 1 commit intomainfrom
t3code/fix-toast-hover-flicker
Mar 9, 2026
Merged

Stabilize visible toast layout offsets to prevent hover flicker#702
juliusmarminge merged 1 commit intomainfrom
t3code/fix-toast-hover-flicker

Conversation

@juliusmarminge
Copy link
Copy Markdown
Member

@juliusmarminge juliusmarminge commented Mar 9, 2026

Summary

  • add buildVisibleToastLayout to compute stable per-toast visibleIndex and cumulative offsetY from the currently visible toast subset
  • normalize toast heights (invalid/missing heights become 0) so layout math remains predictable
  • update toast rendering to use precomputed layout values and CSS variables (--toast-frontmost-height, --toast-index, --toast-offset-y)
  • keep collapsed-content visibility logic intact while switching to layout-derived visible counts
  • add unit tests for layout computation, including mixed heights and missing-height cases

Testing

  • apps/web/src/components/ui/toast.logic.test.ts: verifies visible-index and offset stacking for multiple toast heights
  • apps/web/src/components/ui/toast.logic.test.ts: verifies missing/undefined heights are treated as 0
  • Lint/typecheck: Not run
  • Manual UI verification of hover flicker regression: Not run

Note

Medium Risk
Changes toast stacking/positioning logic and CSS variables, which could cause visual regressions (overlap/jump/flicker) across all toast notifications. Risk is mitigated by added unit tests but still needs quick manual UI verification.

Overview
Stabilizes toast stack layout calculations by introducing buildVisibleToastLayout, which derives a per-visible-toast visibleIndex and cumulative offsetY while normalizing missing/invalid heights to 0.

Updates toast.tsx to render from this computed layout and to pass layout-derived CSS variables (--toast-frontmost-height, --toast-index, --toast-offset-y) into the viewport/toasts, keeping the existing collapsed-content visibility behavior but using the layout’s visible count. Adds unit tests covering offset stacking and missing-height cases.

Written by Cursor Bugbot for commit 95a5ce4. This will update automatically on new commits. Configure here.

Note

Compute toast stack CSS layout variables to stabilize hover offsets in Toasts using buildVisibleToastLayout in toast.tsx

Add buildVisibleToastLayout in toast.logic.ts to compute frontmostHeight, --toast-index, and --toast-offset-y, and update Toasts to consume these values and set CSS variables.

📍Where to Start

Start with buildVisibleToastLayout in toast.logic.ts, then see its usage in Toasts in toast.tsx.

Macroscope summarized 95a5ce4.

- derive toast indices and Y offsets from the filtered visible toasts
- pass frontmost height and per-toast layout vars to the viewport/item styles
- add unit tests for visible toast layout calculations and height normalization
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 9, 2026

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 155d83e1-4b1b-4fcf-824f-05459e680777

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch t3code/fix-toast-hover-flicker

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions github-actions bot added the vouch:trusted PR author is trusted by repo permissions or the VOUCHED list. label Mar 9, 2026
@juliusmarminge juliusmarminge merged commit 24122b1 into main Mar 9, 2026
8 checks passed
@juliusmarminge juliusmarminge deleted the t3code/fix-toast-hover-flicker branch March 9, 2026 17:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

vouch:trusted PR author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant