-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Toast: Race condition on remove #5225
Comments
Yup, it only removes the last toast added regardless of the identifier you provide. |
Thanks a lot for your report! I set a milestone for it. We'll check it before the milestone is released. |
This is not a race condition. Root Cause in Toast.vue
Possible FixUse This will result in the intended behaviour (as if it was object equality) because the id's are unique. Temporary WorkaroundI created a wrapper around useToast which always converts the passed message object into a reactive proxy object. |
In my project I ended up patching with this updated remove function:
` |
Describe the bug
When removing a toast and adding one or more toasts at the same time, the wrong toast may be removed.
The following is the current code in Toast.vue. When a toast is added after index = i and before splice, then the wrong toast is removed, which unfortunately might not even match the condition that was passed to remove.
Reproducer
https://stackblitz.com/edit/primevue-create-vue-typescript-issue-template-gkirw2?file=src%2FApp.vue
PrimeVue version
3.48.0
Vue version
3.x
Language
TypeScript
Build / Runtime
Vite
Browser(s)
No response
Steps to reproduce the behavior
Click the "Trigger" button in the Stackblitz
Expected behavior
The remove function should never remove a task that doesn't match the condition
The text was updated successfully, but these errors were encountered: