Skip to content

Commit

Permalink
fix(module:select,tree-select): prevent pop the dropdown when close c…
Browse files Browse the repository at this point in the history
  • Loading branch information
hsuanxyz committed Oct 17, 2018
1 parent 648da35 commit 51cf722
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 5 deletions.
3 changes: 2 additions & 1 deletion components/cascader/nz-cascader.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
(change)="handlerInputChange($event)">
<i *ngIf="showClearIcon"
nz-icon
type="close"
type="close-circle"
theme="fill"
[ngClass]="clearCls"
[attr.title]="nzClearText"
(click)="clearSelection($event)"></i>
Expand Down
2 changes: 1 addition & 1 deletion components/select/nz-select-top-control.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
[class.ant-select-selection__choice__disabled]="getPropertyFromValue(value,'nzDisabled')"
class="ant-select-selection__choice">
<div class="ant-select-selection__choice__content">{{ getPropertyFromValue(value, 'nzLabel') || value }}</div>
<span *ngIf="!getPropertyFromValue(value,'nzDisabled')" class="ant-select-selection__choice__remove" (click)="removeValueFormSelected(value)">
<span *ngIf="!getPropertyFromValue(value,'nzDisabled')" class="ant-select-selection__choice__remove" (click)="removeValueFormSelected(value, $event)">
<i nz-icon type="close" class="ant-select-remove-icon"></i>
</span>
</li>
Expand Down
7 changes: 6 additions & 1 deletion components/select/nz-select-top-control.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,12 +151,17 @@ export class NzSelectTopControlComponent {
}

// tslint:disable-next-line:no-any
removeValueFormSelected(value: any): void {
removeValueFormSelected(value: any, event?: MouseEvent): void {
if (this.nzDisabled || this.getPropertyFromValue(value, 'nzDisabled')) {
return;
}
this._listOfSelectedValue = this.nzListOfSelectedValue.filter(item => item !== value);
this.nzListOfSelectedValueChange.emit(this.nzListOfSelectedValue);

// Do not trigger the popup
if (event && event.stopPropagation) {
event.stopPropagation();
}
}

updateWidth(): void {
Expand Down
2 changes: 1 addition & 1 deletion components/tree-select/nz-tree-select.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
[attr.title]="nzDisplayWith(node)"
[class.ant-select-selection__choice__disabled]="node.isDisabled"
class="ant-select-selection__choice">
<span *ngIf="!node.isDisabled" class="ant-select-selection__choice__remove" (click)="removeSelected(node)">
<span *ngIf="!node.isDisabled" class="ant-select-selection__choice__remove" (click)="removeSelected(node, true, $event)">
<i nz-icon type="close" class="ant-select-remove-icon"></i>
</span>
<span class="ant-select-selection__choice__content">{{ nzDisplayWith(node) }}</span>
Expand Down
7 changes: 6 additions & 1 deletion components/tree-select/nz-tree-select.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ export class NzTreeSelectComponent implements ControlValueAccessor, OnInit, Afte
}
}

removeSelected(node: NzTreeNode, emit: boolean = true): void {
removeSelected(node: NzTreeNode, emit: boolean = true, event?: MouseEvent): void {
node.isSelected = false;
node.isChecked = false;
if (this.nzCheckable) {
Expand All @@ -251,6 +251,11 @@ export class NzTreeSelectComponent implements ControlValueAccessor, OnInit, Afte
if (emit) {
this.nzRemoved.emit(node);
}

// Do not trigger the popup
if (event && event.stopPropagation) {
event.stopPropagation();
}
}

focusOnInput(): void {
Expand Down

0 comments on commit 51cf722

Please sign in to comment.