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(drawer): fix drawer delay bug for removing from dom #875

Merged
merged 4 commits into from
Jun 3, 2024
Merged
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
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
Loading