Skip to content

Commit 8309185

Browse files
BaharYilmazBahar Yılmaz
and
Bahar Yılmaz
authored
fix(dialog): fix nested dialog propagation problem (#847)
This PR fixes the propagation issue during close in nested dialogs Closes #342 Co-authored-by: Bahar Yılmaz <[email protected]>
1 parent 0de50ae commit 8309185

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

src/components/dialog/bl-dialog.test.ts

+20
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,26 @@ describe("bl-dialog", () => {
208208
await resetMouse();
209209
});
210210

211+
it("should prevent parent dialog from closing when the child dialog is closed", async () => {
212+
const dialog = await fixture<typeOfBlDialog>(html`<bl-dialog id="parent" open>
213+
<bl-dialog id="child" open>
214+
Child dialog
215+
</bl-dialog>
216+
</bl-dialog>`);
217+
218+
const childDialog = dialog.querySelector("bl-dialog") as typeOfBlDialog;
219+
const childDialogCloseBtn = childDialog?.shadowRoot?.querySelector("bl-button");
220+
221+
expect(dialog.open).to.equal(true);
222+
223+
childDialogCloseBtn?.click();
224+
225+
setTimeout(() => {
226+
expect(dialog.open).to.equal(true);
227+
expect(childDialog.open).to.equal(false);
228+
});
229+
});
230+
211231
it("should add shadow to footer when the content is too long", async () => {
212232
window.innerWidth = 400;
213233

src/components/dialog/bl-dialog.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ export default class BlDialog extends LitElement {
111111
this.content?.addEventListener("scroll", this.toggleFooterShadow);
112112
} else {
113113
this.dialog?.close?.();
114-
this.onClose({ isOpen: false });
114+
this.onClose({ isOpen: false }, { bubbles: false });
115115
document.body.style.overflow = "auto";
116116
window?.removeEventListener("keydown", this.onKeydown);
117117
window?.removeEventListener("resize", this.toggleFooterShadow);

0 commit comments

Comments
 (0)