From c5f273a9dc9b9ddcbab06315a82dc7c970e3ce57 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mehmet=20=C3=87etin?= <92744169+mehmetcetin01140@users.noreply.github.com> Date: Fri, 7 Jun 2024 11:16:17 +0300 Subject: [PATCH] Fixed #15400 - Multiselect: selectionLimit not working if the value 0 is provided --- src/app/components/multiselect/multiselect.ts | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/src/app/components/multiselect/multiselect.ts b/src/app/components/multiselect/multiselect.ts index c1e55e47633..afc1f56c8f5 100755 --- a/src/app/components/multiselect/multiselect.ts +++ b/src/app/components/multiselect/multiselect.ts @@ -264,7 +264,7 @@ export class MultiSelectItem {
this.maxSelectedLabels ? this.modelValue().slice(0, this.maxSelectedLabels) : this.modelValue(); }); - constructor( - public el: ElementRef, - public renderer: Renderer2, - public cd: ChangeDetectorRef, - public zone: NgZone, - public filterService: FilterService, - public config: PrimeNGConfig, - public overlayService: OverlayService - ) { + constructor(public el: ElementRef, public renderer: Renderer2, public cd: ChangeDetectorRef, public zone: NgZone, public filterService: FilterService, public config: PrimeNGConfig, public overlayService: OverlayService) { effect(() => { const modelValue = this.modelValue(); @@ -1216,6 +1208,9 @@ export class MultiSelect implements OnInit, AfterViewInit, AfterContentInit, Aft } maxSelectionLimitReached() { + if (this.selectionLimit === 0) { + return true; + } return this.selectionLimit && this.modelValue() && this.modelValue().length === this.selectionLimit; }