Toast: component loses its z-index when using "replace"
Describe the bug
Hello, we found an issue where the replace method make the toaster component loose its z-index value when there is a single message being show. When there are no messages or more than 1 it behaves correctly. We can see, inspecting the DOM, the z-index property disappearing from the toast component.
The onExited function is called by the CSS transition component and it clears the z-index:
https://github.com/primefaces/primereact/blob/f2294cc30eb2d13d36a4556159388ea9dde6ecb4/components/lib/toast/Toast.js#L95
Reproducer
https://stackblitz.com/edit/fx59uvcx?file=src%2FApp.jsx
System Information
Browser: Chrome, Firefox
primereact: 10.8.0, 10.9.7
react: 18.3.1
Steps to reproduce the behavior
- Click "Show dialog"
- Click "Show" once
- Click "Replace": the message gets rendered behind the dialog
Note: we get the correct behavior if we click on "Show" multiple times, or clear all messages and use "Replace" once.
Expected behavior
The replacing message is rendered above the dialog.
Apparently this was changed here: https://github.com/primefaces/primereact/commit/6f510ab8eaefc458dc55c0da69a9967dd06929ca
I tried to solve it but I'm a bit lost, we're passing the nodeRef here: https://github.com/primefaces/primereact/blob/f2294cc30eb2d13d36a4556159388ea9dde6ecb4/components/lib/toast/Toast.js#L149
But I get undefined when I try to retrieve the first argument here: https://github.com/primefaces/primereact/blob/f2294cc30eb2d13d36a4556159388ea9dde6ecb4/components/lib/toast/Toast.js#L94