From cd0b7f30349ebe0bd00813da72728cf259fdad69 Mon Sep 17 00:00:00 2001 From: timon riemslagh Date: Thu, 30 May 2024 15:45:07 +0200 Subject: [PATCH] fix(splitbutton): 15758 add show hide event emitters for the menu --- src/app/components/splitbutton/splitbutton.ts | 24 +++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/src/app/components/splitbutton/splitbutton.ts b/src/app/components/splitbutton/splitbutton.ts index afee3a2f0c4..6dcb1ff7539 100755 --- a/src/app/components/splitbutton/splitbutton.ts +++ b/src/app/components/splitbutton/splitbutton.ts @@ -93,7 +93,8 @@ type SplitButtonIconPosition = 'left' | 'right'; [appendTo]="appendTo" [showTransitionOptions]="showTransitionOptions" [hideTransitionOptions]="hideTransitionOptions" - (onHide)="isExpanded.set(false)" + (onHide)="onHide()" + (onShow)="onShow()" > `, @@ -276,6 +277,16 @@ export class SplitButton { * @group Emits */ @Output() onClick: EventEmitter = new EventEmitter(); + /** + * Callback to invoke when overlay menu is hidden. + * @group Emits + */ + @Output() onMenuHide: EventEmitter = new EventEmitter(); + /** + * Callback to invoke when overlay menu is shown. + * @group Emits + */ + @Output() onMenuShow: EventEmitter = new EventEmitter(); /** * Callback to invoke when dropdown button is clicked. * @param {MouseEvent} event - Mouse event. @@ -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) { @@ -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({