Browse Source

fix(theme-shared): undo keyup changes

pull/1649/head
mehmet-erim 7 years ago
parent
commit
be16db3898
  1. 3
      npm/ng-packs/packages/theme-shared/src/lib/components/modal/modal.component.html
  2. 16
      npm/ng-packs/packages/theme-shared/src/lib/components/modal/modal.component.ts

3
npm/ng-packs/packages/theme-shared/src/lib/components/modal/modal.component.html

@ -1,15 +1,14 @@
<div <div
*ngIf="showModal" *ngIf="showModal"
(click)="close()" (click)="close()"
(keyup.esc)="close()"
id="abp-modal" id="abp-modal"
tabindex="-1"
class="modal fade {{ modalClass }} d-block show" class="modal fade {{ modalClass }} d-block show"
[style.padding-right.px]="'15'" [style.padding-right.px]="'15'"
> >
<div <div
id="abp-modal-container" id="abp-modal-container"
class="modal-dialog modal-{{ size }} fade-in-top" class="modal-dialog modal-{{ size }} fade-in-top"
tabindex="-1"
[class.modal-dialog-centered]="centered" [class.modal-dialog-centered]="centered"
#abpModalContent #abpModalContent
> >

16
npm/ng-packs/packages/theme-shared/src/lib/components/modal/modal.component.ts

@ -12,7 +12,7 @@ import {
ViewChildren, ViewChildren,
} from '@angular/core'; } from '@angular/core';
import { fromEvent, Subject, timer } from 'rxjs'; import { fromEvent, Subject, timer } from 'rxjs';
import { filter, take, takeUntil } from 'rxjs/operators'; import { filter, take, takeUntil, debounceTime } from 'rxjs/operators';
import { Toaster } from '../../models/toaster'; import { Toaster } from '../../models/toaster';
import { ConfirmationService } from '../../services/confirmation.service'; import { ConfirmationService } from '../../services/confirmation.service';
import { ButtonComponent } from '../button/button.component'; import { ButtonComponent } from '../button/button.component';
@ -127,9 +127,18 @@ export class ModalComponent implements OnDestroy {
} }
listen() { listen() {
fromEvent(document, 'keyup')
.pipe(
takeUntil(this.destroy$),
debounceTime(150),
filter((key: KeyboardEvent) => key && key.code === 'Escape' && this.closable),
)
.subscribe(_ => {
this.close();
});
setTimeout(() => { setTimeout(() => {
if (!this.abpClose) return; if (!this.abpClose) return;
fromEvent(this.abpClose.nativeElement, 'click') fromEvent(this.abpClose.nativeElement, 'click')
.pipe( .pipe(
takeUntil(this.destroy$), takeUntil(this.destroy$),
@ -138,7 +147,6 @@ export class ModalComponent implements OnDestroy {
.subscribe(() => this.close()); .subscribe(() => this.close());
}, 0); }, 0);
window.location.hash = '#abp-modal';
this.init.emit(); this.init.emit();
} }
@ -167,8 +175,6 @@ export class ModalComponent implements OnDestroy {
} else { } else {
this.visible = false; this.visible = false;
} }
window.location.hash = 'body';
} }
} }

Loading…
Cancel
Save