diff --git a/src/app/components/treeselect/treeselect.ts b/src/app/components/treeselect/treeselect.ts index 642a9fe286b..282fb372005 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. @@ -917,12 +930,20 @@ export class TreeSelect implements AfterContentInit { 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 {