Skip to content

Commit

Permalink
fix(module:select): fix duplicated option bug (#609)
Browse files Browse the repository at this point in the history
close #590
  • Loading branch information
vthinkxie committed Nov 26, 2017
1 parent 072c97a commit 9385826
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/components/select/nz-select.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -472,8 +472,10 @@ export class NzSelectComponent implements OnInit, AfterContentInit, AfterContent
return (item != null) && (currentModelValue.indexOf(item.nzValue) !== -1);
});
if ((this.nzKeepUnListOptions || this.nzTags) && (!triggerByNgModel)) {
const _selectedOptions = Array.from(this._selectedOptions);
selectedOptions.forEach(option => {
if (!this._selectedOptions.has(option)) {
const _exist = _selectedOptions.some(item => item._value === option._value);
if (!_exist) {
this._selectedOptions.add(option);
}
});
Expand Down Expand Up @@ -514,7 +516,7 @@ export class NzSelectComponent implements OnInit, AfterContentInit, AfterContent
}

handleKeyEnterEvent(event) {
/** when composing end */
/** when composing end */
if (!this._composing && this._isOpen) {
event.preventDefault();
event.stopPropagation();
Expand Down Expand Up @@ -607,7 +609,7 @@ export class NzSelectComponent implements OnInit, AfterContentInit, AfterContent
this.nzOpen = false;
return;
}
if ( (keyCode !== DOWN_ARROW && keyCode !== ENTER) || this.nzOpen) {
if ((keyCode !== DOWN_ARROW && keyCode !== ENTER) || this.nzOpen) {
return;
}
e.preventDefault();
Expand Down

0 comments on commit 9385826

Please sign in to comment.