From 23318823a33091acdfce8d9481f25316af558d43 Mon Sep 17 00:00:00 2001 From: ZhiDanLuo Date: Wed, 12 Jun 2019 21:00:20 +0800 Subject: [PATCH] fix(module:select): remove duplicate drop-down menu options when nzMode === 'tags' (#3559) close #3559 * fix(module:select): remove duplicate drop-down menu options when nzMode === 'tags'(#3559) --- components/select/nz-select.service.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/components/select/nz-select.service.ts b/components/select/nz-select.service.ts index 93c6c92d826..cf5339d675f 100644 --- a/components/select/nz-select.service.ts +++ b/components/select/nz-select.service.ts @@ -182,9 +182,11 @@ 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; @@ -192,7 +194,8 @@ export class NzSelectService { 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); }