Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modified to fix issues in modal backdrop and onclick events handling #708

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions components/modal/modal-options.class.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ export interface ModalOptions {
* Shows the modal when initialized.
*/
show:boolean;
/**
* Ignore the backdrop click
*/
ignoreBackdropClick:boolean;
}

export const modalConfigDefaults:ModalOptions = {
Expand Down
7 changes: 2 additions & 5 deletions components/modal/modal.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ export class ModalDirective implements AfterViewInit, OnDestroy {
protected _isShown:boolean = false;

private isBodyOverflowing:boolean = false;
private ignoreBackdropClick:boolean = false;
private originalBodyPadding:number = 0;
private scrollbarWidth:number = 0;

Expand All @@ -76,8 +75,7 @@ export class ModalDirective implements AfterViewInit, OnDestroy {

@HostListener('click', ['$event'])
protected onClick(event:any):void {
if (this.config.backdrop !== 'static' &&
event.target === this.element.nativeElement) {
if (this.config.ignoreBackdropClick || this.config.backdrop === 'static') {

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.

this.hide(event);
}
}
Expand Down Expand Up @@ -107,7 +105,6 @@ export class ModalDirective implements AfterViewInit, OnDestroy {
// this._backdrop = null
this._isShown = void 0;
this.isBodyOverflowing = void 0;
this.ignoreBackdropClick = void 0;
this.originalBodyPadding = void 0;
this.scrollbarWidth = void 0;

Expand Down Expand Up @@ -226,7 +223,7 @@ export class ModalDirective implements AfterViewInit, OnDestroy {

// todo: original show was calling a callback when done, but we can use promise
private showBackdrop(callback?:Function):void {
if (this._isShown && modalConfigDefaults.backdrop) {
if (this._isShown && this.config.backdrop) {
this.backdrop = this.componentsHelper
.appendNextToRoot(
ModalBackdropComponent,
Expand Down