Skip to content

Commit

Permalink
fix(splitbutton): 15758 add show hide event emitters for the menu
Browse files Browse the repository at this point in the history
  • Loading branch information
tri-harmoney committed May 30, 2024
1 parent de810f3 commit cd0b7f3
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions src/app/components/splitbutton/splitbutton.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,8 @@ type SplitButtonIconPosition = 'left' | 'right';
[appendTo]="appendTo"
[showTransitionOptions]="showTransitionOptions"
[hideTransitionOptions]="hideTransitionOptions"
(onHide)="isExpanded.set(false)"
(onHide)="onHide()"
(onShow)="onShow()"
></p-tieredMenu>
</div>
`,
Expand Down Expand Up @@ -276,6 +277,16 @@ export class SplitButton {
* @group Emits
*/
@Output() onClick: EventEmitter<MouseEvent> = new EventEmitter<MouseEvent>();
/**
* Callback to invoke when overlay menu is hidden.
* @group Emits
*/
@Output() onMenuHide: EventEmitter<any> = new EventEmitter<any>();
/**
* Callback to invoke when overlay menu is shown.
* @group Emits
*/
@Output() onMenuShow: EventEmitter<any> = new EventEmitter<any>();
/**
* Callback to invoke when dropdown button is clicked.
* @param {MouseEvent} event - Mouse event.
Expand Down Expand Up @@ -348,7 +359,6 @@ export class SplitButton {
onDropdownButtonClick(event?: MouseEvent) {
this.onDropdownClick.emit(event);
this.menu?.toggle({ currentTarget: this.containerViewChild?.nativeElement, relativeAlign: this.appendTo == null });
this.isExpanded.set(this.menu.visible);
}

onDropdownButtonKeydown(event: KeyboardEvent) {
Expand All @@ -357,6 +367,16 @@ export class SplitButton {
event.preventDefault();
}
}

onHide() {
this.isExpanded.set(false);
this.onMenuHide.emit();
}

onShow() {
this.isExpanded.set(true);
this.onMenuShow.emit();
}
}

@NgModule({
Expand Down

0 comments on commit cd0b7f3

Please sign in to comment.