From b5fe5d10906b4942bc92fb95c168f11729bff6d4 Mon Sep 17 00:00:00 2001 From: Pablo200206 Date: Sat, 11 May 2024 11:57:51 +0200 Subject: [PATCH 1/2] fix touched --- package-lock.json | 4 +-- src/app/components/treeselect/treeselect.ts | 31 +++++++++++++++++---- 2 files changed, 28 insertions(+), 7 deletions(-) diff --git a/package-lock.json b/package-lock.json index 8ab86a26a62..3b857383e37 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "primeng", - "version": "17.16.0", + "version": "17.16.1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "primeng", - "version": "17.16.0", + "version": "17.16.1", "license": "SEE LICENSE IN LICENSE.md", "devDependencies": { "@angular-devkit/build-angular": "^17.3.6", diff --git a/src/app/components/treeselect/treeselect.ts b/src/app/components/treeselect/treeselect.ts index f6fd4e6521d..7552d463d39 100755 --- a/src/app/components/treeselect/treeselect.ts +++ b/src/app/components/treeselect/treeselect.ts @@ -53,8 +53,8 @@ export const TREESELECT_VALUE_ACCESSOR: any = { [attr.id]="inputId" readonly [disabled]="disabled" - (focus)="onFocus()" - (blur)="onBlur()" + (focus)="onInputFocus($event)" + (blur)="onInputBlur($event)" (keydown)="onKeyDown($event)" [attr.tabindex]="!disabled ? tabindex : -1" [attr.aria-controls]="overlayVisible ? listId : null" @@ -437,6 +437,7 @@ export class TreeSelect implements AfterContentInit { * @group Emits */ @Output() onNodeCollapse: EventEmitter = new EventEmitter(); + /** * Callback to invoke when the overlay is shown. * @param {Event} event - Browser event. @@ -459,6 +460,18 @@ export class TreeSelect implements AfterContentInit { * @group Emits */ @Output() onFilter: EventEmitter = new EventEmitter(); + /** + * Callback to invoke when treeselect gets focus. + * @param {Event} event - Browser event. + * @group Emits + */ + @Output() onFocus: EventEmitter = new EventEmitter(); + /** + * Callback to invoke when treeselect loses focus. + * @param {Event} event - Browser event. + * @group Emits + */ + @Output() onBlur: EventEmitter = new EventEmitter(); /** * Callback to invoke when a node is unselected. * @param {TreeNodeUnSelectEvent} event - node unselect event. @@ -912,17 +925,25 @@ export class TreeSelect implements AfterContentInit { this.focusInput?.nativeElement.focus(); } } - +t onUnselect(event: TreeNodeUnSelectEvent) { this.onNodeUnselect.emit(event); } - onFocus() { + onInputFocus(event: Event) { + if (this.disabled) { + // For ScreenReaders + return; + } + this.focused = true; + this.onFocus.emit(event); } - onBlur() { + onInputBlur(event: Event) { this.focused = false; + this.onBlur.emit(event); + this.onModelTouched(); } writeValue(value: any): void { From 87e9464e63a8ef341904862b16672f9a5c35e7ea Mon Sep 17 00:00:00 2001 From: Pablo200206 Date: Sat, 11 May 2024 12:00:07 +0200 Subject: [PATCH 2/2] fix typo --- src/app/components/treeselect/treeselect.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/components/treeselect/treeselect.ts b/src/app/components/treeselect/treeselect.ts index 7552d463d39..2f0c9e8ca2a 100755 --- a/src/app/components/treeselect/treeselect.ts +++ b/src/app/components/treeselect/treeselect.ts @@ -925,7 +925,7 @@ export class TreeSelect implements AfterContentInit { this.focusInput?.nativeElement.focus(); } } -t + onUnselect(event: TreeNodeUnSelectEvent) { this.onNodeUnselect.emit(event); }