Skip to content

Commit

Permalink
feat: hideOnEscape option for pop
Browse files Browse the repository at this point in the history
  • Loading branch information
felixroos committed Mar 29, 2019
1 parent bcbbc51 commit 7d50c5f
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions packages/ui/src/lib/pop/pop.component.ts
Expand Up @@ -7,7 +7,6 @@ import {
Input,
Output,
HostBinding,
OnInit,
HostListener,
ElementRef,
ChangeDetectionStrategy,
Expand All @@ -33,6 +32,8 @@ export class PopComponent {
@Input() type: string;
/** If set to true, the pop will hide when a click happens outside the pop. */
@Input() hideOnClickOutside = false;
/** If set to false, esc will not close the pop */
@Input() hideOnEscape = true;
// tslint:disable-next-line:no-output-rename
@Output('toggle') _toggle: EventEmitter<boolean> = new EventEmitter();

Expand Down Expand Up @@ -75,7 +76,9 @@ export class PopComponent {
public show(e?) {
this.active = true;
this.activated = true;
this.popService.stack.add(this);
if (this.hideOnEscape) {
this.popService.stack.add(this);
}
if (e) {
this.clickEvent = e;
} else if (this.hideOnClickOutside) {
Expand All @@ -87,7 +90,9 @@ export class PopComponent {

/** Hides the pop. Sets active false and removes pop from popService.stack */
public hide() {
this.popService.stack.remove(this);
if (this.hideOnEscape) {
this.popService.stack.remove(this);
}
this.active = false;
this._toggle.emit(this.active);
this.cdr.markForCheck();
Expand Down

0 comments on commit 7d50c5f

Please sign in to comment.