Skip to content

Commit

Permalink
Merge pull request #15538 from Pablo200206/issue-15537
Browse files Browse the repository at this point in the history
fix(treeselect): #15537 touch on treeselect
  • Loading branch information
cetincakiroglu authored May 14, 2024
2 parents 8351c3f + 87e9464 commit 3ffeede
Showing 1 changed file with 25 additions and 4 deletions.
29 changes: 25 additions & 4 deletions src/app/components/treeselect/treeselect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -437,6 +437,7 @@ export class TreeSelect implements AfterContentInit {
* @group Emits
*/
@Output() onNodeCollapse: EventEmitter<TreeSelectNodeCollapseEvent> = new EventEmitter<TreeSelectNodeCollapseEvent>();

/**
* Callback to invoke when the overlay is shown.
* @param {Event} event - Browser event.
Expand All @@ -459,6 +460,18 @@ export class TreeSelect implements AfterContentInit {
* @group Emits
*/
@Output() onFilter: EventEmitter<TreeFilterEvent> = new EventEmitter<TreeFilterEvent>();
/**
* Callback to invoke when treeselect gets focus.
* @param {Event} event - Browser event.
* @group Emits
*/
@Output() onFocus: EventEmitter<Event> = new EventEmitter<Event>();
/**
* Callback to invoke when treeselect loses focus.
* @param {Event} event - Browser event.
* @group Emits
*/
@Output() onBlur: EventEmitter<Event> = new EventEmitter<Event>();
/**
* Callback to invoke when a node is unselected.
* @param {TreeNodeUnSelectEvent} event - node unselect event.
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 3ffeede

Please sign in to comment.