Hide notifications when clicking dropdown button

This commit is contained in:
Sipke Schoorstra 2023-05-01 15:51:17 +02:00
parent a8387cb964
commit f345910116
3 changed files with 7 additions and 2 deletions

View file

@ -1061,6 +1061,7 @@ declare namespace LocalJSX {
"icon"?: any;
"items"?: Array<DropdownButtonItem>;
"onItemSelected"?: (event: ElsaDropdownButtonCustomEvent<DropdownButtonItem>) => void;
"onMenuOpened"?: (event: ElsaDropdownButtonCustomEvent<void>) => void;
"origin"?: DropdownButtonOrigin;
"text"?: string;
"theme"?: ('Primary' | 'Secondary');

View file

@ -15,6 +15,7 @@ export class DropdownButton {
@Prop() public items: Array<DropdownButtonItem> = [];
@Prop() public theme: ('Primary' | 'Secondary') = 'Primary';
@Event() public itemSelected: EventEmitter<DropdownButtonItem>
@Event() public menuOpened: EventEmitter<void>
private contextMenu: HTMLElement;
private element: HTMLElement;
@ -102,8 +103,10 @@ export class DropdownButton {
}
private toggleMenu() {
if (!!this.contextMenu)
if (!!this.contextMenu) {
toggle(this.contextMenu);
this.menuOpened.emit();
}
}
private getOriginClass(): string {

View file

@ -1,5 +1,6 @@
import {Component, Event, EventEmitter, h, Prop} from '@stencil/core';
import {DropdownButtonItem} from "../../../components/shared/dropdown-button/models";
import NotificationService from "../../notifications/notification-service";
export interface PublishClickedArgs {
begin: () => void;
@ -73,6 +74,6 @@ export class PublishButton {
handler: publishing ? () => {} : () => this.onPublishClick()
}
return <elsa-dropdown-button text={mainItem.text} handler={mainItem.handler} items={items} icon={this.publishingIcon()} />
return <elsa-dropdown-button text={mainItem.text} handler={mainItem.handler} items={items} icon={this.publishingIcon()} onMenuOpened={() => NotificationService.hideAllNotifications()} />
}
}