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/Messages: remove not working #5083

Closed
rpiaggio opened this issue Oct 11, 2023 · 10 comments · Fixed by #5090
Closed

Toast/Messages: remove not working #5083

rpiaggio opened this issue Oct 11, 2023 · 10 comments · Fixed by #5090
Assignees
Labels
Type: Bug Issue contains a defect related to a specific component.
Milestone

Comments

@rpiaggio
Copy link
Contributor

rpiaggio commented Oct 11, 2023

Describe the bug

Support to remove specific toast messages was added in #3457.

However, this doesn't seem to work. A peek at the implementation seems to identify the shown message by the _pId property, which is inaccesible by the client code.

Reproducer

https://codesandbox.io/s/primereact-test-forked-bbns8k?file=/src/index.js

PrimeReact version

10.0.3

React version

17.x

Language

TypeScript

Build / Runtime

Create React App (CRA)

Browser(s)

No response

Steps to reproduce the behavior

  1. Call toastRef.current.show(msg).
  2. Call toastRef.current.remove(msg).
  3. Toast is not removed.

Expected behavior

Toast is removed.

@rpiaggio rpiaggio added the Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible label Oct 11, 2023
@rpiaggio
Copy link
Contributor Author

Messages may suffer from the same issue.

@melloware
Copy link
Member

@rpiaggio have you debugged for a potential solution?

@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 Oct 11, 2023
@rpiaggio
Copy link
Contributor Author

rpiaggio commented Oct 11, 2023

One possible solution is to make the show and replace methods return the indexed objects created by assignIdentifiers. It seems if one of those objects are passed to remove, it would work.

@melloware
Copy link
Member

yeah this is tricky. I know the clear method works to remove all messages but I am assuming you are targeting a specific message to remove.

@rpiaggio
Copy link
Contributor Author

Yes, that's the case.

@melloware
Copy link
Member

i will take a look and see if I can fix it.

@melloware melloware self-assigned this Oct 11, 2023
@melloware melloware added this to the 10.0.4 milestone Oct 11, 2023
@melloware melloware changed the title Toast.remove not working Toast/Messages: remove not working Oct 11, 2023
melloware added a commit to melloware/primereact that referenced this issue Oct 12, 2023
@melloware
Copy link
Member

Check out my PR. I check for either ID equality or if you pass a message like you are message equality of the JSON object.

@rpiaggio
Copy link
Contributor Author

This seems like it should work, thank you! I'll eagerly await for the release.

@melloware
Copy link
Member

i tested it locally and its working so crossing my fingers! Keep your eye out for a 10.0.4 release and let me know how it goes.

@melloware
Copy link
Member

OK 10.0.4 is out if you want to test this fix.

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