Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(treeselect): #15537 ng-touch on treeselect #15538

Merged
merged 2 commits into from
May 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

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
Loading