diff --git a/packages/main/cypress/specs/Dialog.cy.tsx b/packages/main/cypress/specs/Dialog.cy.tsx index dc16054d69f4..0520bb89aa8a 100644 --- a/packages/main/cypress/specs/Dialog.cy.tsx +++ b/packages/main/cypress/specs/Dialog.cy.tsx @@ -1,4 +1,5 @@ import "@ui5/webcomponents-base/dist/features/F6Navigation.js"; +import ResizeHandler from "@ui5/webcomponents-base/dist/delegate/ResizeHandler.js"; import Dialog from "../../src/Dialog.js"; import Label from "../../src/Label.js"; import Title from "../../src/Title.js"; @@ -379,6 +380,32 @@ describe("Dialog general interaction", () => { .should("not.be.visible"); }); + it("dialog ResizeHandler registration", () => { + cy.spy(ResizeHandler, "register").as("registerResizeSpy"); + + cy.mount( + <> + +
Content
+
+ + ); + + cy.get("#dialog") + .should((dialog => { + expect(dialog.get(0).getDomRef()).to.exist; + })); + + cy.get("@registerResizeSpy") + .should("not.be.called"); + + cy.get("#dialog") + .invoke("attr", "open", true); + + cy.get("@registerResizeSpy") + .should("be.calledOnce"); + }); + it("dialog repositions after screen resize", () => { cy.mount( diff --git a/packages/main/src/Popup.ts b/packages/main/src/Popup.ts index fa486e761d42..69a439209610 100644 --- a/packages/main/src/Popup.ts +++ b/packages/main/src/Popup.ts @@ -272,11 +272,17 @@ abstract class Popup extends UI5Element { renderFinished().then(() => { this._updateMediaRange(); }); + + ResizeHandler.deregister(this, this._resizeHandler); + + if (this._opened) { + ResizeHandler.register(this, this._resizeHandler); + } } onEnterDOM() { this.setAttribute("popover", "manual"); - ResizeHandler.register(this, this._resizeHandler); + if (isDesktop()) { this.setAttribute("desktop", ""); } diff --git a/packages/main/test/pages/Dialog.html b/packages/main/test/pages/Dialog.html index d66094cad107..b22a9d3d7108 100644 --- a/packages/main/test/pages/Dialog.html +++ b/packages/main/test/pages/Dialog.html @@ -83,6 +83,9 @@

Open dialog calling ".open = true" multiple times +
+
+ Open dialog with big content @@ -719,6 +722,113 @@ open + + + + + + + + + +