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 and message onRemove argument is not a ToastMessage type when it has _pId #6784

Closed
lukelalo opened this issue Jun 21, 2024 · 9 comments · Fixed by #7108 · May be fixed by leoo1992/GeradorQRCode#95
Closed

Toast and message onRemove argument is not a ToastMessage type when it has _pId #6784

lukelalo opened this issue Jun 21, 2024 · 9 comments · Fixed by #7108 · May be fixed by leoo1992/GeradorQRCode#95
Assignees
Labels
Type: Bug Issue contains a defect related to a specific component.
Milestone

Comments

@lukelalo
Copy link
Contributor

Describe the bug

Hi,

I've seen some changes in toast/message code and I think these changes may have broken the onRemove call parameters:

image

In the first call to onRemove it may not have the ._pId attribute, but in the second call it has it, and instead of sending the ToastMessage in onRemove function it returns the _pId.

I think the onRemove call should be called with messageInfo.message || messageInfo instead of removeMessage.

Regards
Pablo García

Reproducer

No response

PrimeReact version

10.6.6

React version

17.x

Language

ES6

Build / Runtime

Create React App (CRA)

Browser(s)

No response

Steps to reproduce the behavior

  • Create a Toast or Message
  • Show the message
  • Click on onRemove button (it contains a message as first parameter)
  • Show the message again
  • Click on onRemove button (it contains a number as first parameter)

Expected behavior

  • Create a Toast or Message
  • Show the message
  • Click on onRemove button (it contains a message as first parameter)
  • Show the message again
  • Click on onRemove button (it contains a message as first parameter)
@lukelalo lukelalo added the Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible label Jun 21, 2024
@lukelalo lukelalo changed the title Toast and message onRemove argument is not a ToastMessage type when it has an _pId Toast and message onRemove argument is not a ToastMessage type when it has _pId Jun 21, 2024
@melloware
Copy link
Member

@Rekl0w i think he means this fix: #6457

@melloware
Copy link
Member

melloware commented Jun 21, 2024

Agreed you should be able to do this...

toastRef.current.remove({ id: messageId  });

but that is not working.

@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 Jun 21, 2024
@lukelalo
Copy link
Contributor Author

lukelalo commented Jun 21, 2024

My main issue is I don't know what to do with the _pId, as I have all the information in my process stored on the ToastMessage, and also receiving two distinct arguments in the same function is some sort of... messy

@lukelalo
Copy link
Contributor Author

@Rekl0w i think he means this fix: #6457

Yes

@melloware
Copy link
Member

@lukelalo here is a demo i did for another user that works but it requires you to keep the message to remove it.

https://stackblitz.com/edit/gque6v?file=src%2FApp.jsx

@lukelalo
Copy link
Contributor Author

lukelalo commented Jun 21, 2024

Yep, but this demo doesn't use the onRemove method. As a workaround is not bad, but shouldn't be awesome that the onRemove method did its work?

@melloware
Copy link
Member

yeah your issue is definitely a bug.

@elvis1994
Copy link

Hi, I also experimenting a bug due to this issue. Only at first interaction with close, the argument passed to the remove function is the entire message object instead of a pId, which cause the remove of all messages which are the same. From the second interaction the argument is a pId and the close action works correctly, only the specific message with that pId is removed.

@lukelalo
Copy link
Contributor Author

lukelalo commented Aug 14, 2024

Similar to #5972

@melloware melloware added this to the 10.8.3 milestone Sep 4, 2024
melloware pushed a commit that referenced this issue Sep 4, 2024
* Fixed toast onRemove message

* Fixed Messages.js onRemove message

---------

Co-authored-by: pablo.garcia.almis <[email protected]>
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
3 participants