Skip to content

Commit

Permalink
fix(module:select): remove duplicate drop-down menu options when nzMo…
Browse files Browse the repository at this point in the history
…de === 'tags' (NG-ZORRO#3559)

close NG-ZORRO#3559

* fix(module:select): remove duplicate drop-down menu options when nzMode === 'tags'(NG-ZORRO#3559)
  • Loading branch information
lzdw committed Jun 13, 2019
1 parent e59171b commit 2331882
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions components/select/nz-select.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,17 +182,20 @@ export class NzSelectService {
// https://github.com/NG-ZORRO/ng-zorro-antd/issues/3424
this.listOfTagOption = [...this.listOfCachedSelectedOption, ...this.listOfSelectedValue].reduce(
(options: NzOptionComponent[], componentOrValue) => {
// https://github.com/NG-ZORRO/ng-zorro-antd/issues/3559
if (
typeof componentOrValue === 'string' &&
!this.listOfTemplateOption.find(o => this.compareWith(o.nzValue, componentOrValue))
!this.listOfTemplateOption.find(o => this.compareWith(o.nzValue, componentOrValue)) &&
!options.some(o => o.nzValue === componentOrValue)
) {
const nzOptionComponent = new NzOptionComponent();
nzOptionComponent.nzValue = componentOrValue;
nzOptionComponent.nzLabel = componentOrValue;
options.push(nzOptionComponent);
} else if (
componentOrValue.nzValue &&
!this.listOfTemplateOption.find(o => this.compareWith(o.nzValue, componentOrValue.nzValue))
!this.listOfTemplateOption.find(o => this.compareWith(o.nzValue, componentOrValue.nzValue)) &&
!options.some(o => o.nzValue === componentOrValue.nzValue)
) {
options.push(componentOrValue);
}
Expand Down

0 comments on commit 2331882

Please sign in to comment.