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

fix(module:modal): integration problem with select component #3245

Merged
merged 2 commits into from
Apr 19, 2019
Merged
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
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