Skip to content

Commit

Permalink
fix(module:modal): integration problem with select component (#3245)
Browse files Browse the repository at this point in the history
* fix(module:modal): integration problem with select component

close #3213

* style: fix lint
  • Loading branch information
hsuanxyz authored and vthinkxie committed Apr 19, 2019
1 parent 74d996b commit 3da4b68
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 32 deletions.
24 changes: 0 additions & 24 deletions components/modal/modal-util.ts

This file was deleted.

4 changes: 2 additions & 2 deletions components/modal/nz-modal.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
<i nz-icon type="close" class="ant-modal-close-icon"></i>
</span>
</button>
<ng-container [ngSwitch]="!hidden">
<ng-container *ngIf="!hidden" [ngSwitch]="true">
<ng-container *ngSwitchCase="isModalType('default')" [ngTemplateOutlet]="tplContentDefault"></ng-container>
<ng-container *ngSwitchCase="isModalType('confirm')" [ngTemplateOutlet]="tplContentConfirm"></ng-container>
</ng-container>
Expand Down Expand Up @@ -100,7 +100,7 @@
</ng-container>
</span>
<div class="ant-modal-confirm-content">
<ng-container #bodyContainer>
<ng-container>
<ng-container *ngIf="!isComponent(nzContent)" [ngSwitch]="true">
<ng-container *ngSwitchCase="isTemplateRef(nzContent)" [ngTemplateOutlet]="nzContent"></ng-container>
<ng-container *ngSwitchCase="isNonEmptyString(nzContent)"><div [innerHTML]="nzContent"></div></ng-container>
Expand Down
13 changes: 7 additions & 6 deletions components/modal/nz-modal.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,9 @@ import {
import { fromEvent, Observable, Subject } from 'rxjs';
import { takeUntil } from 'rxjs/operators';

import { isPromise, InputBoolean } from 'ng-zorro-antd/core';
import { getElementOffset, isPromise, InputBoolean } from 'ng-zorro-antd/core';
import { NzI18nService } from 'ng-zorro-antd/i18n';

import ModalUtil from './modal-util';
import { NzModalConfig, NZ_MODAL_CONFIG } from './nz-modal-config';
import { NzModalControlService } from './nz-modal-control.service';
import { NzModalRef } from './nz-modal-ref.class';
Expand Down Expand Up @@ -472,10 +471,12 @@ export class NzModalComponent<T = any, R = any> extends NzModalRef<T, R>
// Update transform-origin to the last click position on document
private updateTransformOrigin(): void {
const modalElement = this.modalContainer.nativeElement as HTMLElement;
const lastPosition = ModalUtil.getLastClickPosition();
if (lastPosition) {
this.transformOrigin = `${lastPosition.x - modalElement.offsetLeft}px ${lastPosition.y -
modalElement.offsetTop}px 0px`;
if (this.previouslyFocusedElement) {
const previouslyDOMRect = this.previouslyFocusedElement.getBoundingClientRect();
const lastPosition = getElementOffset(this.previouslyFocusedElement);
const x = lastPosition.left + previouslyDOMRect.width / 2;
const y = lastPosition.top + previouslyDOMRect.height / 2;
this.transformOrigin = `${x - modalElement.offsetLeft}px ${y - modalElement.offsetTop}px 0px`;
}
}

Expand Down

0 comments on commit 3da4b68

Please sign in to comment.