From 5382e4b26bb47494a7d9febd525d9413b5502e35 Mon Sep 17 00:00:00 2001 From: Ravinder Payal Date: Tue, 2 May 2017 14:27:41 +0530 Subject: [PATCH 1/6] Update menu-directive.ts --- src/lib/menu/menu-directive.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/lib/menu/menu-directive.ts b/src/lib/menu/menu-directive.ts index 502f490c02fe..449c26d27d98 100644 --- a/src/lib/menu/menu-directive.ts +++ b/src/lib/menu/menu-directive.ts @@ -54,6 +54,9 @@ export class MdMenu implements AfterContentInit, MdMenuPanel, OnDestroy { @ContentChildren(MdMenuItem) items: QueryList; @Input() overlapTrigger = true; + /** Wether the preventClose for menu instance is asked or not.*/ + @Input("preventClose") preventClose:boolean = false; + constructor(@Attribute('xPosition') posX: MenuPositionX, @Attribute('yPosition') posY: MenuPositionY, @Attribute('x-position') deprecatedPosX: MenuPositionX, @@ -114,6 +117,17 @@ export class MdMenu implements AfterContentInit, MdMenuPanel, OnDestroy { _emitCloseEvent(): void { this.close.emit(); } + + /** + * This emits a close event to which the trigger is subscribed, only when a user + * click inside menu panel and prevent close attribute/input is false. When emitted, + * the trigger will close the menu. + */ + _emitClickCloseEvent(): void { + if(!this.preventClose){ + this.close.emit(); + } + } private _setPositionX(pos: MenuPositionX): void { if (pos !== 'before' && pos !== 'after') { From d3ffd6039769beda9f0c79b9fc07108a9c543374 Mon Sep 17 00:00:00 2001 From: Ravinder Payal Date: Tue, 2 May 2017 14:32:03 +0530 Subject: [PATCH 2/6] Update menu.html Changed the on click callback methodto `_emitClickCloseEvent` as this method as an additional logic for checking if `preventClose` is asked or not. --- src/lib/menu/menu.html | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/lib/menu/menu.html b/src/lib/menu/menu.html index 989bf1f56acb..259f65994967 100644 --- a/src/lib/menu/menu.html +++ b/src/lib/menu/menu.html @@ -1,9 +1,8 @@
+ (click)="_emitClickCloseEvent()" [@transformMenu]="'showing'">
- From 842af8a61bc6940677e6bb2c4f60d545aadc3df5 Mon Sep 17 00:00:00 2001 From: Ravinder Payal Date: Tue, 2 May 2017 19:04:20 +0530 Subject: [PATCH 3/6] Update menu.html From 72d06e3113bd33dfe866b24097fe7bd88289b96b Mon Sep 17 00:00:00 2001 From: Ravinder Payal Date: Tue, 2 May 2017 19:07:03 +0530 Subject: [PATCH 4/6] Update menu-directive.ts satisfied travis-CI --- src/lib/menu/menu-directive.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/lib/menu/menu-directive.ts b/src/lib/menu/menu-directive.ts index 449c26d27d98..6cc58cb805ba 100644 --- a/src/lib/menu/menu-directive.ts +++ b/src/lib/menu/menu-directive.ts @@ -55,7 +55,7 @@ export class MdMenu implements AfterContentInit, MdMenuPanel, OnDestroy { @Input() overlapTrigger = true; /** Wether the preventClose for menu instance is asked or not.*/ - @Input("preventClose") preventClose:boolean = false; + @Input('preventClose') preventClose: boolean = false; constructor(@Attribute('xPosition') posX: MenuPositionX, @Attribute('yPosition') posY: MenuPositionY, @@ -117,14 +117,14 @@ export class MdMenu implements AfterContentInit, MdMenuPanel, OnDestroy { _emitCloseEvent(): void { this.close.emit(); } - + /** * This emits a close event to which the trigger is subscribed, only when a user * click inside menu panel and prevent close attribute/input is false. When emitted, * the trigger will close the menu. */ _emitClickCloseEvent(): void { - if(!this.preventClose){ + if( !this.preventClose ){ this.close.emit(); } } From a8c6f91bcffb24ef1635a4e6e8ba67c7d26108f2 Mon Sep 17 00:00:00 2001 From: Ravinder Payal Date: Tue, 2 May 2017 19:23:49 +0530 Subject: [PATCH 5/6] Update menu-directive.ts satisfying travis-CI --- src/lib/menu/menu-directive.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/menu/menu-directive.ts b/src/lib/menu/menu-directive.ts index 6cc58cb805ba..a033bb2733d9 100644 --- a/src/lib/menu/menu-directive.ts +++ b/src/lib/menu/menu-directive.ts @@ -124,7 +124,7 @@ export class MdMenu implements AfterContentInit, MdMenuPanel, OnDestroy { * the trigger will close the menu. */ _emitClickCloseEvent(): void { - if( !this.preventClose ){ + if (!this.preventClose) { this.close.emit(); } } From 6f4954351285c9388b424a7978f3363dfeb31271 Mon Sep 17 00:00:00 2001 From: Ravinder Payal Date: Thu, 25 May 2017 02:25:12 +0530 Subject: [PATCH 6/6] Update menu-directive.ts --- src/lib/menu/menu-directive.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/lib/menu/menu-directive.ts b/src/lib/menu/menu-directive.ts index a033bb2733d9..ba18c534f91b 100644 --- a/src/lib/menu/menu-directive.ts +++ b/src/lib/menu/menu-directive.ts @@ -1,4 +1,5 @@ // TODO(kara): prevent-close functionality +// wasn't this supposed to be from an outside developer who needs this feature urgently? import { AfterContentInit,