fix(Toaster): prevent onClick from being called twice - #6980
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (2)
Included review availability: Your plan provides up to 8 included reviews per hour; 6 remain after this review. 📝 WalkthroughWalkthroughThe Priority: ➖ Normal Estimated code review effort: 2 (Simple) | ~10 minutes Severity of issue fixed: Medium Merge Risk: ⚪ Minimal · up to The toast click fix satisfies the stated behavior and no concrete merge-blocking risk remains. 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
commit: |
🔗 Linked issue
Resolves #6972
❓ Type of change
📚 Description
Toasterspreads the whole toast onto<UToast>and also binds@click="toast.onClick && toast.onClick(toast)".ToastPropshas noonClickprop andToastEmitsnoclickemit, so the spreadonClickfalls through as a second native listener.mergePropsonly drops a duplicate when both handlers are the same function reference, and the inline one isn't, so a single click runs the user handler twice: once with theMouseEvent, once with theToast. The second call also contradicts the documentedonClick?: (toast: Toast) => voidsignature, and any handler that isn't idempotent, adding a toast for instance, does its work twice.This adds
onClickto theomitlist so only the explicit@clicksurvives, the same fix as cbed0cc forEditorToolbarin #5784, with a test inToast.spec.tsthat clicks a rendered toast and counts the calls.📝 Checklist