diff --git a/components/lib/messages/Messages.js b/components/lib/messages/Messages.js index 7b15bbd295..8d64f0fa92 100644 --- a/components/lib/messages/Messages.js +++ b/components/lib/messages/Messages.js @@ -73,7 +73,7 @@ export const Messages = React.memo( const remove = (messageInfo) => { // allow removal by ID or by message equality - const removeMessage = messageInfo._pId ? messageInfo.message : messageInfo; + const removeMessage = messageInfo._pId ? messageInfo._pId : messageInfo.message || messageInfo; setMessagesState((prev) => prev.filter((msg) => msg._pId !== messageInfo._pId && !ObjectUtils.deepEquals(msg.message, removeMessage))); diff --git a/components/lib/toast/Toast.js b/components/lib/toast/Toast.js index 12cf4f1b42..53834183cf 100644 --- a/components/lib/toast/Toast.js +++ b/components/lib/toast/Toast.js @@ -76,7 +76,7 @@ export const Toast = React.memo( const remove = (messageInfo) => { // allow removal by ID or by message equality - const removeMessage = messageInfo._pId ? messageInfo.message : messageInfo; + const removeMessage = messageInfo._pId ? messageInfo._pId : messageInfo.message || messageInfo; setMessagesState((prev) => prev.filter((msg) => msg._pId !== messageInfo._pId && !ObjectUtils.deepEquals(msg.message, removeMessage)));