Skip to content
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 remove function removes all toasts with the same message when action is done on toast with pId = 0 #7483

Closed
elvis1994 opened this issue Dec 6, 2024 · 1 comment · Fixed by #7484
Assignees
Labels
Type: Bug Issue contains a defect related to a specific component.
Milestone

Comments

@elvis1994
Copy link

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;

Screenshot 2024-12-06 180137

Screenshot 2024-12-06 180201

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

PrimeReact version
10.8.5

React version
18.2

Language
ES6

Build / Runtime
Create React App (CRA)

Browser(s)
No response

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

@elvis1994 elvis1994 added the Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible label Dec 6, 2024
@elvis1994 elvis1994 changed the title Toast remove function remove all toasts with the same message when action is done on toast with pId = 0 Toast remove function removes all toasts with the same message when action is done on toast with pId = 0 Dec 6, 2024
@melloware melloware added Type: Bug Issue contains a defect related to a specific component. and removed Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible labels Dec 6, 2024
@melloware melloware self-assigned this Dec 6, 2024
@melloware melloware added this to the 10.8.6 milestone Dec 6, 2024
melloware added a commit to melloware/primereact that referenced this issue Dec 6, 2024
@melloware
Copy link
Member

PR submitted

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug Issue contains a defect related to a specific component.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants