Skip to content

Commit

Permalink
fix: EventDispatcher allow events without payload
Browse files Browse the repository at this point in the history
  • Loading branch information
0o001 committed Jan 11, 2024
1 parent ecc8a30 commit 8ad84f9
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 13 deletions.
6 changes: 2 additions & 4 deletions src/components/drawer/bl-drawer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,16 +74,14 @@ export default class BlDrawer extends LitElement {
}

this.domExistence = true;
// FIXME: Allow events without payload
this.onOpen("");
this.onOpen();
} else {
// Give some time for exit animation
this.domExistenceSchedule = window.setTimeout(() => {
this.domExistence = false;
}, 1000);

// FIXME: Allow events without payload
this.onClose("");
this.onClose();
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/components/popover/bl-popover.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ export default class BlPopover extends LitElement {
show() {
this._visible = true;
this.setPopover();
this.onBlPopoverShow("");
this.onBlPopoverShow();
document.addEventListener("click", this._handleClickOutside);
document.addEventListener("keydown", this._handleKeydownEvent);
document.addEventListener("bl-popover-show", this._handlePopoverShowEvent);
Expand All @@ -207,7 +207,7 @@ export default class BlPopover extends LitElement {
document.removeEventListener("click", this._handleClickOutside);
document.removeEventListener("keydown", this._handleKeydownEvent);
document.removeEventListener("bl-popover-show", this._handlePopoverShowEvent);
this.onBlPopoverHide("");
this.onBlPopoverHide();
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/components/tooltip/bl-tooltip.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ describe("bl-tooltip", () => {
const ev = await oneEvent(el, "bl-tooltip-show");

expect(ev).to.exist;
expect(ev.detail).to.be.equal("");
expect(ev.detail).to.be.null;
});

it("should fires bl-tooltip-hide on mouse leave", async () => {
Expand All @@ -169,7 +169,7 @@ describe("bl-tooltip", () => {
const ev = await oneEvent(el, "bl-tooltip-hide");

expect(ev).to.exist;
expect(ev.detail).to.be.equal("");
expect(ev.detail).to.be.null;
});

it("should show/hide with focus and blur events", async () => {
Expand Down
6 changes: 3 additions & 3 deletions src/components/tooltip/bl-tooltip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,15 @@ export default class BlTooltip extends LitElement {
show() {
this.popover.target = this.trigger;
this.popover.show();
this.onShow("");
this.onShow();
}

/**
* Hides tooltip
*/
hide() {
this.popover.hide();
this.onHide("");
this.onHide();
}

/**
Expand Down Expand Up @@ -83,7 +83,7 @@ export default class BlTooltip extends LitElement {
<bl-popover
.target="${this.trigger}"
placement="${ifDefined(this.placement)}"
@bl-popover-hide="${() => this.onHide("")}"
@bl-popover-hide="${() => this.onHide()}"
>
<slot class="content" id="tooltip" role="tooltip"></slot>
</bl-popover>
Expand Down
4 changes: 2 additions & 2 deletions src/utilities/event.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ export interface EventOptions {
}

export interface EventDispatcher<T> {
(value: T, options?: EventOptions): CustomEvent<T>;
(value?: T, options?: EventOptions): CustomEvent<T>;
}

function dispatcher<T>(target: HTMLElement, eventName: string): EventDispatcher<T> {
return function (value: T, options?: EventOptions) {
return function (value?: T, options?: EventOptions) {
const customEvent = new CustomEvent<T>(eventName, {
detail: value,
bubbles: true,
Expand Down

0 comments on commit 8ad84f9

Please sign in to comment.