From 6561d03ce96ad6c4317e150f7760718675bad8a2 Mon Sep 17 00:00:00 2001 From: Ed Carroll Date: Mon, 14 Aug 2017 05:45:42 +0100 Subject: [PATCH 1/4] fix(select): Fixed destroyed view errors --- src/modules/select/classes/select-base.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/modules/select/classes/select-base.ts b/src/modules/select/classes/select-base.ts index d6f147e84..c7b682f9f 100644 --- a/src/modules/select/classes/select-base.ts +++ b/src/modules/select/classes/select-base.ts @@ -1,6 +1,6 @@ import { ViewChild, HostBinding, ElementRef, HostListener, Input, ContentChildren, QueryList, - AfterContentInit, TemplateRef, ViewContainerRef, ContentChild, EventEmitter, Output + AfterContentInit, TemplateRef, ViewContainerRef, ContentChild, EventEmitter, Output, OnDestroy } from "@angular/core"; import { Subscription } from "rxjs/Subscription"; import { DropdownService, SuiDropdownMenu } from "../../dropdown"; @@ -16,7 +16,7 @@ export interface IOptionContext extends ITemplateRefContext { // We use generic type T to specify the type of the options we are working with, // and U to specify the type of the property of the option used as the value. -export abstract class SuiSelectBase implements AfterContentInit { +export abstract class SuiSelectBase implements AfterContentInit, OnDestroy { public dropdownService:DropdownService; public searchService:SearchService; @@ -322,7 +322,7 @@ export abstract class SuiSelectBase implements AfterContentInit { this.drawTemplate(option.templateSibling, option.value); } - option.changeDetector.detectChanges(); + option.changeDetector.markForCheck(); } public abstract selectOption(option:T):void; @@ -418,4 +418,8 @@ export abstract class SuiSelectBase implements AfterContentInit { query: this.query }); } + + public ngOnDestroy():void { + this._renderedSubscriptions.forEach(s => s.unsubscribe()); + } } From 17705f56c9dd7782b1a1a40963d6bea29ae82d26 Mon Sep 17 00:00:00 2001 From: Ed Carroll Date: Mon, 14 Aug 2017 05:46:04 +0100 Subject: [PATCH 2/4] fix(modal): Fix modal auto closing when clicked --- src/modules/modal/components/modal.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/modules/modal/components/modal.ts b/src/modules/modal/components/modal.ts index 29f4602f4..543ddc6d0 100644 --- a/src/modules/modal/components/modal.ts +++ b/src/modules/modal/components/modal.ts @@ -28,6 +28,7 @@ import { ModalConfig, ModalSize } from "../classes/modal-config"; [class.scroll]="mustScroll" [class.inverted]="isInverted" [ngClass]="dynamicClasses" + (click)="onClick($event)" #modal> @@ -282,6 +283,11 @@ export class SuiModal implements OnInit, AfterViewInit { } } + public onClick(e:MouseEvent):void { + // Makes sense here, as the modal shouldn't be attached to any DOM element. + e.stopPropagation(); + } + @HostListener("document:keyup", ["$event"]) public onDocumentKeyup(e:KeyboardEvent):void { if (e.keyCode === KeyCode.Escape) { From d014d1a25537423a87141bf68b4121763b2af863 Mon Sep 17 00:00:00 2001 From: Ed Carroll Date: Mon, 14 Aug 2017 05:46:17 +0100 Subject: [PATCH 3/4] fix(popup): Removed console log in focus handler --- src/modules/popup/classes/popup-controller.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/modules/popup/classes/popup-controller.ts b/src/modules/popup/classes/popup-controller.ts index a54eac728..0a93dc674 100644 --- a/src/modules/popup/classes/popup-controller.ts +++ b/src/modules/popup/classes/popup-controller.ts @@ -167,7 +167,6 @@ export abstract class SuiPopupController implements IPopup, OnDestroy { @HostListener("focusout", ["$event"]) private onFocusOut(e:any):void { - console.log(e.relatedTarget); if (!this._element.nativeElement.contains(e.relatedTarget) && !this.popup.elementRef.nativeElement.contains(e.relatedTarget) && this.popup.config.trigger === PopupTrigger.Focus) { From 305bf38478806d48fa2b1713fbe4e7b7207b71fb Mon Sep 17 00:00:00 2001 From: Ed Carroll Date: Mon, 14 Aug 2017 05:46:29 +0100 Subject: [PATCH 4/4] fix(popup): Forced import of TemplateRef --- src/modules/popup/directives/popup.directive.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/modules/popup/directives/popup.directive.ts b/src/modules/popup/directives/popup.directive.ts index fd8f8c54d..ae309e558 100644 --- a/src/modules/popup/directives/popup.directive.ts +++ b/src/modules/popup/directives/popup.directive.ts @@ -6,6 +6,8 @@ import { SuiPopupConfig } from "../services/popup.service"; import { SuiPopupController } from "../classes/popup-controller"; import { SuiPopupTemplateController, ITemplatePopupContext, ITemplatePopupConfig } from "../classes/popup-template-controller"; +const templateRef = TemplateRef; + @Directive({ selector: "[suiPopup]", exportAs: "suiPopup"