ng-sidebar icon indicating copy to clipboard operation
ng-sidebar copied to clipboard

Intercept click on Backdrop

Open panagulis72 opened this issue 7 years ago • 2 comments

Hi, I'm using Angular 6 and RxJS6. I'm saving into the application Store a boolean, 'isSidenavOpened'. All works fine, but I enabled the backdrop and I'm not able to intercept the click on it. In fact, I would like to set the 'isSidenavOpened' variable to false

panagulis72 avatar Jul 09 '18 13:07 panagulis72

There's output events that tell you when the sidebar has opened or closed, so you probably don't need to intercept the click on the backdrop.

arkon avatar Jul 11 '18 22:07 arkon

I used onCloseStart, but if I close the sidebar clicking on the backdrop it dispatch two actions of type "CLOSE_SIDEBAR". So it works, even if it is dispatched twice:

<ng-sidebar [(opened)]="isMainMenuSidebarOpened" mode="over" keyClose="true" position="left" closeOnClickBackdrop="true" showBackdrop="true" animate="true" trapFocus="true" autoFocus="true" sidebarClass="main-menu-sidebar" ariaLabel="Menu" (onCloseStart)="onMainMenuSidenavClose()"> <p translate="mainMenuSidenav.MAIN_MENU" class="title">

app.component.ts: onMainMenuSidenavClose(): void { this.store.dispatch(new CoreActions.CloseMainMenuSidebar()); }

If I click the button that close the sidenav (and call the function onMainMenuSidenavClose()) the action is dispatched just one time.

So, it was just for code cleaning. The ng-sidebar component has many interesting features, it really has everything (good job), but it would not bad to add the ability to intercept the click on the backdrop. Could be useful to someone, even more than me! Thank you!

panagulis72 avatar Jul 12 '18 06:07 panagulis72