From 3163fe2a26021a6014190aa1efb3b445152fe46e Mon Sep 17 00:00:00 2001 From: "AKOVALENKO-NB\\andrii.kovalenko" Date: Fri, 19 Jan 2024 14:54:34 +0200 Subject: [PATCH 1/2] added maxlength property to p-chips component --- src/app/components/chips/chips.spec.ts | 8 ++++++++ src/app/components/chips/chips.ts | 6 ++++++ src/app/showcase/doc/apidoc/index.json | 9 ++++++++- 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/src/app/components/chips/chips.spec.ts b/src/app/components/chips/chips.spec.ts index 263dfce3d6d..e7b3737f9bf 100755 --- a/src/app/components/chips/chips.spec.ts +++ b/src/app/components/chips/chips.spec.ts @@ -258,6 +258,14 @@ describe('Chips', () => { expect(inputEl.nativeElement.disabled).toEqual(false); }); + it('should set maxlength to input element', () => { + chips.max = 2; + fixture.detectChanges(); + + const inputEl = fixture.debugElement.query(By.css('input')); + expect(inputEl.attributes.maxlength).toEqual('2'); + }); + it('should delete item', () => { chips.value = ['primeng']; fixture.detectChanges(); diff --git a/src/app/components/chips/chips.ts b/src/app/components/chips/chips.ts index dafd9c4ea7e..8e133614afc 100755 --- a/src/app/components/chips/chips.ts +++ b/src/app/components/chips/chips.ts @@ -77,6 +77,7 @@ export const CHIPS_VALUE_ACCESSOR: any = { #inputtext type="text" [attr.id]="inputId" + [attr.maxlength]="maxLength" [attr.placeholder]="value && value.length ? null : placeholder" [attr.tabindex]="tabindex" (keydown)="onKeyDown($event)" @@ -140,6 +141,11 @@ export class Chips implements AfterContentInit, ControlValueAccessor { * @group Props */ @Input() max: number | undefined; + /** + * Maximum chip length. + * @group Props + */ + @Input() maxLength: number | undefined; /** * Defines a string that labels the input for accessibility. * @group Props diff --git a/src/app/showcase/doc/apidoc/index.json b/src/app/showcase/doc/apidoc/index.json index 6c00dc35e36..432af3aa3db 100644 --- a/src/app/showcase/doc/apidoc/index.json +++ b/src/app/showcase/doc/apidoc/index.json @@ -7190,6 +7190,13 @@ "type": "number", "description": "Maximum number of entries allowed." }, + { + "name": "maxLength", + "optional": false, + "readonly": false, + "type": "number", + "description": "Maximum length of chip." + }, { "name": "ariaLabel", "optional": false, @@ -27736,4 +27743,4 @@ } } } -} \ No newline at end of file +} From 340c051ce76d5b7a4f1974dbed6d291ba5e3810c Mon Sep 17 00:00:00 2001 From: "AKOVALENKO-NB\\andrii.kovalenko" Date: Fri, 19 Jan 2024 16:40:47 +0200 Subject: [PATCH 2/2] added maxlength property to p-chips component --- src/app/components/chips/chips.ts | 2 +- src/app/showcase/doc/apidoc/index.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/app/components/chips/chips.ts b/src/app/components/chips/chips.ts index 8e133614afc..5f498a50bf7 100755 --- a/src/app/components/chips/chips.ts +++ b/src/app/components/chips/chips.ts @@ -142,7 +142,7 @@ export class Chips implements AfterContentInit, ControlValueAccessor { */ @Input() max: number | undefined; /** - * Maximum chip length. + * Maximum length of a chip. * @group Props */ @Input() maxLength: number | undefined; diff --git a/src/app/showcase/doc/apidoc/index.json b/src/app/showcase/doc/apidoc/index.json index 432af3aa3db..ca3faf38644 100644 --- a/src/app/showcase/doc/apidoc/index.json +++ b/src/app/showcase/doc/apidoc/index.json @@ -7195,7 +7195,7 @@ "optional": false, "readonly": false, "type": "number", - "description": "Maximum length of chip." + "description": "Maximum length of a chip." }, { "name": "ariaLabel",