Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: EventDispatcher allow events without payload #756

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/components/drawer/bl-drawer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,21 +111,21 @@ export default class BlDrawer extends LitElement {
clearTimeout(this.domExistenceSchedule);
}
this.domExistence = true;

window.setTimeout(() => {
if (this.embedUrl && this._drawerIframe) {
this._drawerIframe.src = this.embedUrl;
}
});
// 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 @@ -195,7 +195,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 @@ -209,7 +209,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
14 changes: 8 additions & 6 deletions src/components/tooltip/bl-tooltip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,17 +97,19 @@
* Shows tooltip
*/
show() {
this._popover.target = this.target ?? this.trigger;
this._popover.show();
this.onShow("");

Check failure on line 100 in src/components/tooltip/bl-tooltip.ts

View workflow job for this annotation

GitHub Actions / verify / verify

Replace `⏎` with `··`

Check failure on line 100 in src/components/tooltip/bl-tooltip.ts

View workflow job for this annotation

GitHub Actions / verify / verify

Replace `⏎` with `··`
this._popover.target = this.target ?? this.trigger;
this._popover.show();

Check failure on line 102 in src/components/tooltip/bl-tooltip.ts

View workflow job for this annotation

GitHub Actions / verify / verify

Insert `··`

Check failure on line 102 in src/components/tooltip/bl-tooltip.ts

View workflow job for this annotation

GitHub Actions / verify / verify

Insert `··`
this.onShow();

Check failure on line 103 in src/components/tooltip/bl-tooltip.ts

View workflow job for this annotation

GitHub Actions / verify / verify

Replace `··` with `····`

Check failure on line 103 in src/components/tooltip/bl-tooltip.ts

View workflow job for this annotation

GitHub Actions / verify / verify

Replace `··` with `····`
}

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

Check failure on line 110 in src/components/tooltip/bl-tooltip.ts

View workflow job for this annotation

GitHub Actions / verify / verify

Replace `⏎` with `··`

Check failure on line 110 in src/components/tooltip/bl-tooltip.ts

View workflow job for this annotation

GitHub Actions / verify / verify

Replace `⏎` with `··`
this._popover.hide();
this.onHide();

Check failure on line 112 in src/components/tooltip/bl-tooltip.ts

View workflow job for this annotation

GitHub Actions / verify / verify

Insert `··`

Check failure on line 112 in src/components/tooltip/bl-tooltip.ts

View workflow job for this annotation

GitHub Actions / verify / verify

Insert `··`
}

/**
Expand Down Expand Up @@ -136,7 +138,7 @@
<bl-popover
.target="${this.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
Loading