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

Open
lukelalo opened this issue Jun 21, 2024 · 7 comments
Labels
Type: Bug Issue contains a defect related to a specific component.

Comments

@lukelalo
Copy link

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
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
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
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.

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

No branches or pull requests

2 participants