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 autoZIndex not working correctly #6825

Closed
ribizli opened this issue Nov 6, 2018 · 9 comments
Closed

Toast autoZIndex not working correctly #6825

ribizli opened this issue Nov 6, 2018 · 9 comments
Assignees
Labels
Type: Bug Issue contains a bug related to a specific component. Something about the component is not working
Milestone

Comments

@ribizli
Copy link

ribizli commented Nov 6, 2018

I'm submitting a ...

[X] bug report => Search github for a similar issue or PR before submitting
[ ] feature request => Please check if request is not on the roadmap already https://github.com/primefaces/primeng/wiki/Roadmap
[ ] support request => Please do not submit support request here, instead see http://forum.primefaces.org/viewforum.php?f=35

Plunkr Case (Bug Reports)

https://stackblitz.com/edit/primeng-toast-autozindex

Current behavior
The toast's zIndex is set only once after view init. Every time a modal dialog is opened, the DomHandler.zindex is increased and the dialog mask gets a higher zIndex as our toast was set initially. So every toast messages are overlaid, which is not the desired behavior.

Expected behavior
Increment toast zIndex to not be overlaid by dialog mask.

Minimal reproduction of the problem with instructions
See above.
A possible solution could be to implement the ngDoCheck lifecycle method to increase the zIndex if needed. (I'm not fully sure about the negative performance impacts of this)

  • Angular version: 6.1
  • PrimeNG version: 6.1.5

The source code hasn't change in this regard since then.

  • Browser: [Chrome ]

zIndex must be supported in all browsers in the same way.

  • Language: [TypeScript 2.9]
@yigitfindikli
Copy link
Contributor

You need to give baseZIndex.
<p-toast [baseZIndex]="100"></p-toast>
And please use forum for questions and help requests.

@ribizli
Copy link
Author

ribizli commented Nov 7, 2018

This wasn't a help request! This is definitely an issue. I'm reading the source code before reporting such issues, and believe me, I know what I'm doing.

p-dialog increases its zIndex on every mousedown (moveOnTop()), so it can happen soon that the DomHandler.zindex gets over the +100. After opening the next modal dialog, the toast will be already behind. Sure I could specify 1000 or 10000 for baseZIndex, but this it is just question of time when dialog's zIndex it gets over it.

But anyway the name autoZIndex of the input of p-toast suggests it will be maintained so, that it is always on top. But this is not the case, and so misleading. Currently this attribute has no real effect, only that initially a zIndex is set for the component. (Since toast is mostly a global component near to the root of the application tree, it is initiated early and once with the application start)

I solved this issue currently in my app using a wrapper component and a workaround:

  @ViewChild(Toast)
  toast: Toast;

  ngDoCheck() {
      if (!(this.toast && this.toast.containerViewChild)) return;
      const requiredZIndex = `${DomHandler.zindex}`;
      const el = this.toast.containerViewChild.nativeElement as HTMLElement;
      if (el.style.zIndex !== requiredZIndex) el.style.zIndex = requiredZIndex;
  }

The code above ensures that the Toast container is always above the dialog's mask.

But I think this logic should be in the Toast itself.

So please re-open this issue.

@mbuchner
Copy link

mbuchner commented Nov 7, 2018

+1

@cagataycivici cagataycivici reopened this Nov 7, 2018
@cagataycivici cagataycivici self-assigned this Nov 7, 2018
@cagataycivici cagataycivici added this to the 7.0.0-beta.2 milestone Nov 7, 2018
@cagataycivici cagataycivici added the Type: Enhancement Issue contains an enhancement related to a specific component. Additional functionality has been add label Nov 7, 2018
@cagataycivici cagataycivici added Type: Bug Issue contains a bug related to a specific component. Something about the component is not working and removed Type: Enhancement Issue contains an enhancement related to a specific component. Additional functionality has been add labels Nov 27, 2018
@PhamVanthinh2801
Copy link

PhamVanthinh2801 commented May 9, 2022

i have issue that, but now, i want fixed them...

@JohnStaikos
Copy link

Same problem still persists

@carlos-gomez-espinosa
Copy link

still persists on v14.2.3

@jmattgiroux
Copy link

I too have this issue.

@OrestisKariotis
Copy link

In my case, what @ribizli said was exactly the issue, but I had to set the zIndex to a value higher than the required zIndex for the toast to appear above my dialog. Namely:

el.style.zIndex = requiredZIndex + 1;

I'm not that experienced in CSS properties manipulating, so I am unaware of whether providing values higher than the required zIndex might have side-effects.

@Arthur-Carbonari
Copy link

Arthur-Carbonari commented Jan 21, 2024

So this is not fixed, toasts are being displayed behind the dialogs overlay even if we declare the toast's z-base-index. Why this hasn't been fixed even tho its been identified years ago is beyond me.
To clarify this happen if the toast is declared outside the dialog and its getting fetched by key. If you declare the toast inside the dialog it will work. BUT the expected behavior should be that toast should be displayed above the dialog, even if declared outside of it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug Issue contains a bug related to a specific component. Something about the component is not working
Projects
None yet
Development

No branches or pull requests

10 participants