Skip to content

Commit

Permalink
Fixed #13998 - Add missing onClick emitter
Browse files Browse the repository at this point in the history
  • Loading branch information
cetincakiroglu committed Nov 4, 2023
1 parent d069e90 commit 66d1480
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/app/components/listbox/listbox.interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export interface ListboxClickEvent {
/**
* Selected option
*/
option: any;
option?: any;
}
/**
* Custom change event.
Expand Down
7 changes: 7 additions & 0 deletions src/app/components/listbox/listbox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -749,6 +749,13 @@ export class Listbox implements AfterContentInit, OnInit, ControlValueAccessor,
this.value = value;
this.modelValue.set(value);
this.onModelChange(value);

if(event && event.type == 'click') {
this.onClick.emit({
originalEvent: event,
value: value
});
}
}

removeOption(option) {
Expand Down
6 changes: 5 additions & 1 deletion src/app/showcase/doc/listbox/basicdoc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ interface City {
</p>
</app-docsectiontext>
<div class="card flex justify-content-center">
<p-listbox [options]="cities" [(ngModel)]="selectedCity" optionLabel="name" [style]="{ width: '15rem' }" [listStyle]="{ 'max-height': '220px' }"></p-listbox>
<p-listbox [options]="cities" [(ngModel)]="selectedCity" optionLabel="name" [style]="{ width: '15rem' }" [listStyle]="{ 'max-height': '220px' }" (onClick)="onClick($event)"></p-listbox>
</div>
<app-code [code]="code" selector="listbox-basic-demo"></app-code>
</section>`
Expand All @@ -31,6 +31,10 @@ export class BasicDoc implements OnInit {

selectedCity!: City;

onClick(event) {
console.log(event)
}

ngOnInit() {
this.cities = [
{ name: 'New York', code: 'NY' },
Expand Down

0 comments on commit 66d1480

Please sign in to comment.