primeng icon indicating copy to clipboard operation
primeng copied to clipboard

V12 - sidebar doesn't remove mask

Open jiangyh1024 opened this issue 5 years ago • 32 comments

  disableModality() {
        if (this.mask) {
            DomHandler.addClass(this.mask, 'p-component-overlay-leave');
            this.animationEndListener = this.destroyModal.bind(this);
            this.mask.addEventListener('animationend', this.animationEndListener);
        }
    }

    destroyModal() {
        this.unbindMaskClickListener();
        document.body.removeChild(this.mask);

        if (this.blockScroll) {
            DomHandler.removeClass(document.body, 'p-overflow-hidden');
        }

        this.unbindAnimationEndListener();
        this.mask = null;
    }

doesn't trigger destroyModal()

jiangyh1024 avatar Sep 28 '21 09:09 jiangyh1024

This is still not fixed. Since mask element is after the sidebar when we set appendTo="body" and the click event on buttons which are placed inside the sidebar components are not preventDefault, then animationend event not triggered. We used custom buttons to close the sidebar.

Its still not working. Easy fix could be add event listener with useCaptue as true

@jiangyh1024 Please reopen this bug

vimalraj-a avatar Sep 29 '21 12:09 vimalraj-a

Still exists in 12.2.0

szymonhel avatar Oct 06 '21 21:10 szymonhel

I have looked into this a little. It appears that the animationEndListener that's supposed to destroy the overlay is removed before the panel is entirely hidden. This is done through unbindGlobalListeners

    onAnimationEnd(event) {
        switch (event.toState) {
            case 'void':
                this.hide(); // Binds `destroyModal` to the mask `animationend`
                ZIndexUtils.clear(this.container);
                this.unbindGlobalListeners(); // Removes `destroyModal` from the mask immediately
                break;
        }
    }

A possible solution is to simply move the hide to after the unbindGlobalListeners.

AmazingDreams avatar Oct 07 '21 08:10 AmazingDreams

On second thought, I think unbindAnimationEndListener should be removed from unbindGlobalListeners

AmazingDreams avatar Oct 07 '21 08:10 AmazingDreams

seems fixed, when to release a new version

jiangyh1024 avatar Oct 13 '21 07:10 jiangyh1024

I am still seeing this issue in our project after updating to 12.2.1. Neither the 2-way binding to [(visible)] nor clicking off the sidebar [dismissible]="true" clears the mask.

KeithGillette avatar Oct 14 '21 19:10 KeithGillette

try what I did in #10715, I think it could fix this issue as a makeshift.

jiangyh1024 avatar Oct 15 '21 01:10 jiangyh1024

Thanks for the suggestion, @jiangyh1024. I have added a ViewChild(Sidebar) and tried to call hide() on it manually prior to setting the [(visible)] binding to false in our component controller per your recommended work-around, but the mask still remains after the sidebar closes.

I do not think that this issue should be closed.

KeithGillette avatar Oct 15 '21 02:10 KeithGillette

I have been unable to reproduce the problem using the Sidebar Stackblitz example, but this issue still occurs in our PWA under PrimeNG 12.2.1 & Angular 12.2.10. However, I found I could work-around the problem by manually calling destroyModal() onHide:

<p-sidebar
	#NavSideBar
	(onHide)="NavSideBar.destroyModal()"
	[(visible)]="navigationPaneIsOpen"
	[blockScroll]="true"
	[showCloseIcon]="false"
	styleClass="p-0"
	appendTo="body">
		...
</p-sidebar>

KeithGillette avatar Oct 18 '21 21:10 KeithGillette

Thx, that would be helpful

jiangyh1024 avatar Oct 19 '21 00:10 jiangyh1024

I can still reproduce the issue in the version 12.2.1. The problem is that the p-component-overlay div is not removed when the sidebar is closed. To reproduce the issue you cannot use a theme because in the theme there are some css transitions to remove the panel. So, my workaround is add the next lines (copied to one theme) to my style.scss file

.p-component-overlay-enter {
  animation: p-component-overlay-enter-animation 150ms forwards;
}

.p-component-overlay-leave {
  animation: p-component-overlay-leave-animation 150ms forwards;
}

@keyframes p-component-overlay-enter-animation {
  from {
    background-color: transparent;
  }
  to {
    background-color: var(--maskbg);
  }
}
@keyframes p-component-overlay-leave-animation {
  from {
    background-color: var(--maskbg);
  }
  to {
    background-color: transparent;
  }
}

Anyway I attach a minimal angular project to reproduce the issue

sidebar-issue.zip

smarrerof avatar Oct 20 '21 13:10 smarrerof

Thanks, @smarrerof. Those CSS animations fix the problem and eliminate the need for the work-around I previously posted in our project, which doesn't use a standard PrimeNG theme and was missing those .p-component-overlay-* selectors in our custom theme SCSS.

KeithGillette avatar Oct 20 '21 14:10 KeithGillette

Thanks @smarrerof. I can confirm that the problem persists, but this workaround works.

kumaheiyama avatar Oct 25 '21 13:10 kumaheiyama

Many thanks , @smarrerof , your workaround is effective and smart. Issue should be reopened , and maybe fixed with it :)

karlatt avatar Oct 26 '21 15:10 karlatt

Why is this closed if it is still broken? I have the problem with 12.2.2

ccit-spence avatar Nov 04 '21 11:11 ccit-spence

Still present in latest 12.x version. Please fix.

lufo88ita avatar Nov 08 '21 09:11 lufo88ita

Also still present for me with 12.2.2

markusvorraber avatar Nov 12 '21 10:11 markusvorraber

Confirm, bug is still present in 12.2.2

olaisen81 avatar Nov 12 '21 15:11 olaisen81

Still present in 13 RC2

akill-es avatar Nov 17 '21 14:11 akill-es

Is this still present in 13.0.2?

mmulligan5c avatar Dec 20 '21 15:12 mmulligan5c