Skip to content

Commit

Permalink
fix(drawer): fix drawer delay bug for removing from dom (#875)
Browse files Browse the repository at this point in the history
Closes #536
  • Loading branch information
fatihkucuktry authored Jun 3, 2024
1 parent 3373a39 commit 5e4ef0e
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/components/drawer/bl-drawer.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { CSSResultGroup, html, LitElement, TemplateResult } from "lit";
import { PropertyValues } from "lit";
import { customElement, property, state } from "lit/decorators.js";
import { customElement, property, query, state } from "lit/decorators.js";
import { event, EventDispatcher } from "../../utilities/event";
import { styleToPixelConverter } from "../../utilities/style-to-px.converter";
import "../button/bl-button";
Expand Down Expand Up @@ -59,6 +59,9 @@ export default class BlDrawer extends LitElement {
*/
@event("bl-drawer-close") private onClose: EventDispatcher<string>;

@query("#drawer-iframe")
_drawerIframe: HTMLIFrameElement;

connectedCallback() {
super.connectedCallback();
window?.addEventListener("bl-drawer-open", event => {
Expand Down Expand Up @@ -107,8 +110,12 @@ export default class BlDrawer extends LitElement {
if (this.domExistenceSchedule) {
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("");
} else {
Expand All @@ -130,7 +137,7 @@ export default class BlDrawer extends LitElement {

private renderContent() {
const content = this.embedUrl
? html`<iframe src=${this.embedUrl}></iframe>`
? html`<iframe id="drawer-iframe" src=${this.embedUrl}></iframe>`
: html`<slot></slot>`;

return html`<section class=${this.embedUrl ? "iframe-content" : "content"}>
Expand Down

0 comments on commit 5e4ef0e

Please sign in to comment.