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

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

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

Loading…
Cancel
Save