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

Component: Sidebar #14254

Closed
Sp94dev opened this issue Nov 30, 2023 · 12 comments · Fixed by #14438
Closed

Component: Sidebar #14254

Sp94dev opened this issue Nov 30, 2023 · 12 comments · Fixed by #14438
Assignees
Labels
Type: Bug Issue contains a bug related to a specific component. Something about the component is not working
Milestone

Comments

@Sp94dev
Copy link

Sp94dev commented Nov 30, 2023

Describe the bug

When trying to close the sidebar, the sidebar-mask disappears but the component stays open.
(onHide) is not triggered.

Environment

Standard angular application

Reproducer

https://stackblitz.com/edit/774ddz?file=src%2Fapp%2Fdemo%2Fsidebar-basic-demo.html

Angular version

17.1.0

PrimeNG version

17.0.0-rc.1

Build / Runtime

Angular CLI App

Language

TypeScript

Node version (for AoT issues node --version)

v18.17.0.

Browser(s)

Chrome

Steps to reproduce the behavior

  1. Open sidebar
  2. Close sidebar

Expected behavior

(onHide) should call closeSidebar method

@Sp94dev Sp94dev added the Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible label Nov 30, 2023
@eXpertise7
Copy link

eXpertise7 commented Nov 30, 2023

@Sp94dev unfortunately you are right... just when I thought [email protected] (last version of angular 16, equal as yours) is production ready after months of waiting..

This issue occurs only is p-sidebar has default or implicitly set [modal]="true", on [modal]="false" everything works normally.

What is interesting, sometimes (onHide) EventEmitter from p-sidebar works, but after couple of times it stops to destroy p-sidebar HTML content.

Thank you for testing this (from another FE Developer user of PrimeNG).

@eXpertise7
Copy link

eXpertise7 commented Nov 30, 2023

My experience is that I can tell that when [(visible)] ngModel variable if p-sidebar has two race conditions (two booleans), on manipulating these booleans at User Developer codebase - PrimeNG will set one p-sidebar EventEmitter (onHide) correctly, but it will not set second p-sidebar (destroy a component there) in the same view.

Splitting these two race conditions from one p-sidebar, into two separate p-sidebar's at my side did the trick (no issues anymore), but issue is persistent still with p-sidebar in mentioned case.

I hope that'll help some of users to temporarily fix that issue at your codebase, and that PrimeNG team will find what's the issue and solve it quick.

@Sp94dev
Copy link
Author

Sp94dev commented Nov 30, 2023

@eXpertise7 could You show an example?

@eXpertise7
Copy link

eXpertise7 commented Nov 30, 2023

@eXpertise7 could You show an example?

I've different case, I'm using normal public boolean variables, not Signal's.

Before it was this, it has worked in the [email protected] (my version):

<p-sidebar
  position="right"
  [(visible)]="showFirstSidebarContent || showSecondSidebarContent"
  (onHide)="closeSidebar()">
    <app-first-component *ngIf="showFirstSidebarContent"></app-first-component>
    <app-second-component *ngIf="showSecondSidebarContent"></app-second-component>
</p-sidebar>
  closeSidebar(): void {
    // apply sidebar flags because we have 2 conditions in 2 way databinding visible prop
    // usually we don't need this approach
    this.showFirstSidebarContent = false;
    this.showSecondSidebarContent = false;
  }

On [email protected] it does not work.

So I needed to split (without using (onHide) event method) one p-sidebar into two p-sidebar's usage:

<p-sidebar
  position="right"
  [(visible)]="showFirstSidebarContent"
>
  <app-first-component *ngIf="showFirstSidebarContent"></<app-first-component>
</p-sidebar>
<p-sidebar
  position="right"
  [(visible)]="showSecondSidebarContent"
>
  <app-second-component *ngIf="showSecondSidebarContent"></app-admin-group-guide>
</p-sidebar>

This is not issue solve of p-sidebar unappropriate (onHide) event usage, this could be just for some people temporarily workaround.

@Sp94dev
Copy link
Author

Sp94dev commented Nov 30, 2023

Ahh yes, In my case setting [modal]=false helps a little but it is not a solution because I lost overlay and a click outside of sidebar behaviours.

@gabboman
Copy link

In my case it worked fine with primeng16 in general, but when updated to angular 17 started getting this issue too. Temporaly I will set modal to false

@Sp94dev
Copy link
Author

Sp94dev commented Dec 11, 2023

After some testing, I noted that the bug started occurring in 16.8.0, and in 16.5.0 everything worked fine.

@gabboman
Copy link

Issue still happens at 17.1.0

mehmetcetin01140 added a commit that referenced this issue Dec 27, 2023
…r-mask disappears but the component stays open
@cetincakiroglu cetincakiroglu added this to the 17.3.0 milestone Dec 28, 2023
@cetincakiroglu cetincakiroglu added Type: Bug Issue contains a bug related to a specific component. Something about the component is not working and removed Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible labels Dec 28, 2023
cetincakiroglu added a commit that referenced this issue Dec 28, 2023
Fixed #14254 - Sidebar | When trying to close the sidebar, the sideba…
@mountpoint
Copy link

mountpoint commented Dec 28, 2023

@cetincakiroglu

in version 17.3.0 when you try to close programatically by setting [(visible)]="isVisible" sidebar disappears but the mask stays visible. So I downgraded back to 17.2.0
Screenshot 2023-12-28 181058

@cetincakiroglu cetincakiroglu modified the milestones: 17.3.0, 17.3.1 Dec 28, 2023
@github-actions github-actions bot added the Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible label Dec 28, 2023
@cetincakiroglu cetincakiroglu modified the milestones: 17.3.1, 17.3.0 Dec 29, 2023
@cetincakiroglu cetincakiroglu removed the Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible label Dec 29, 2023
@cetincakiroglu
Copy link
Contributor

@cetincakiroglu

in version 17.3.0 when you try to close programatically by setting [(visible)]="isVisible" sidebar disappears but the mask stays visible. So I downgraded back to 17.2.0 Screenshot 2023-12-28 181058

could you please create a separate issue with a stackblitz reproducer for this?

@riker09
Copy link
Contributor

riker09 commented Jan 2, 2024

Maybe this is helpful. I have a p-menu component inside the p-sidebar and when I click on one of the menu items the p-sidebar is closed and if I immediately spam-click on the p-overlay it gets closed sometimes? It reliably works with one specific link in my menu while others don't.

@Melliche
Copy link

Melliche commented Jul 5, 2024

Hello, the problem is still present with the latest versions of Angular 17, if I modify the value of visible, the onHide event is not triggered, I use these dependencies:

"dependencies": {
    "@angular/animations": "^17.3.11",
    "@angular/cdk": "^17.3.10",
    "@angular/common": "^17.3.11",
    "@angular/compiler": "^17.3.11",
    "@angular/core": "^17.3.11",
    "@angular/forms": "^17.3.11",
    "@angular/platform-browser": "^17.3.11",
    "@angular/platform-browser-dynamic": "^17.3.11",
    "@angular/router": "^17.3.11",
    "@jsverse/transloco": "^7.4.2",
    "angular-oauth2-oidc": "13.0.1",
    "dayjs": "^1.11.11",
    "lodash": "^4.17.21",
    "primeflex": "^3.3.1",
    "primeicons": "^6.0.1",
    "primeng": "^17.18.1",
    "rxjs": "~7.8.1",
    "tslib": "^2.6.2",
    "uuid": "^9.0.0",
    "zone.js": "~0.14.7"
  },

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

Successfully merging a pull request may close this issue.

8 participants