Skip to content

fix(Toast): remove viewport listeners when a toast is dismissed - #2809

Merged
zernonia merged 1 commit into
unovue:v2from
lazerg:fix/toast-viewport-listener-cleanup
Jul 23, 2026
Merged

zernonia merged 1 commit into
unovue:v2from
lazerg:fix/toast-viewport-listener-cleanup

Conversation

@lazerg

@lazerg lazerg commented Jul 22, 2026 •

Copy link
Copy Markdown
Contributor

Each toast registers pause and resume listeners on the shared viewport inside a watchEffect, but the teardown was returned from the effect callback instead of being registered through its cleanup argument, so watchEffect silently discarded it. Every dismissed toast therefore left its listeners and detached <li> subtree attached to the viewport, leaking on each open/close cycle. This registers the cleanup through the watchEffect cleanup callback so the listeners are removed when the toast unmounts.

Fixes #2782

Summary by CodeRabbit

  • Bug Fixes
    • Toast notifications now properly remove viewport event listeners when dismissed.
    • Improved cleanup of pause and resume behavior to prevent lingering event handlers.

@coderabbitai

coderabbitai Bot commented Jul 22, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: cfefd1f5-64c6-444e-a760-628023cbe72d

📥 Commits

Reviewing files that changed from the base of the PR and between 6e340d6 and 839c039.

📒 Files selected for processing (2)
  • packages/core/src/Toast/Toast.test.ts
  • packages/core/src/Toast/ToastRootImpl.vue

📝 Walkthrough

Walkthrough

Toast viewport listener teardown now uses the watch effect cleanup callback. Tests cover removal of both pause and resume listeners when a Toast is dismissed.

Changes

Toast listener cleanup

Layer / File(s) Summary
Register and verify Toast listener cleanup
packages/core/src/Toast/ToastRootImpl.vue, packages/core/src/Toast/Toast.test.ts
Viewport pause and resume listeners register cleanup through cleanupFn, and a dismissal test verifies both listeners are removed.

Estimated code review effort: 2 (Simple) | ~10 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the core change: removing toast viewport listeners on dismissal.
Linked Issues check ✅ Passed The code updates cleanup registration in watchEffect and adds a test confirming paused/resume listeners are removed on dismiss, satisfying #2782.
Out of Scope Changes check ✅ Passed The changes stay focused on Toast listener cleanup and its test coverage, with no obvious unrelated additions.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

ESLint install failed. For unrecoverable errors, disable the tool in CodeRabbit configuration.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@zernonia

Copy link
Copy Markdown
Member

Thanks for the PR @lazerg !

@pkg-pr-new

pkg-pr-new Bot commented Jul 23, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/reka-ui@2809

commit: 839c039

@zernonia
zernonia merged commit 6ff2c63 into unovue:v2 Jul 23, 2026
7 checks passed
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]: Toast viewport listeners are never removed (watchEffect cleanup returned instead of registered) — every dismissed toast leaks its DOM subtree

2 participants