Toast remove function removes all toasts with the same message when action is done on toast with pId = 0 #7483
Labels
Type: Bug
Issue contains a defect related to a specific component.
Milestone
Describe the bug
Hi,
I’ve identified an issue with the remove function in the toast component. The problem occurs when clicking the remove button of the first toast (which has pId = 0). This causes all toasts (with the same messageInfo.message || messageInfo) to be removed, rather than just the intended one.
The root cause seems to be the following expression:
const removeMessage = messageInfo._pId ? messageInfo._pId : messageInfo.message || messageInfo;
When the pId of the message is 0, it is treated as a falsy value. As a result, the expression evaluates to messageInfo.message || messageInfo, leading to unexpected behavior.
Please let me know if you need further details or assistance in resolving this.
Best regards,
Elvira Zanin
Reproducer
No response
System Information
Steps to reproduce the behavior
Create and show more then one toast (with same message)
Click on the button to remove the first toast (which has pID = 0)
-> It removes all the toasts.
Expected behavior
It removes only the first toast
The text was updated successfully, but these errors were encountered: