primereact icon indicating copy to clipboard operation
primereact copied to clipboard

Toast: component loses its z-index when using "replace"

Open RolT opened this issue 1 month ago • 2 comments

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

  1. Click "Show dialog"
  2. Click "Show" once
  3. 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.

RolT avatar Nov 21 '25 10:11 RolT

Apparently this was changed here: https://github.com/primefaces/primereact/commit/6f510ab8eaefc458dc55c0da69a9967dd06929ca

RolT avatar Nov 27 '25 15:11 RolT

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

RolT avatar Nov 27 '25 16:11 RolT