Skip to content

Commit

Permalink
fix(ui5-popup): fix(ui5-popup): hide block layer if popup is closed (#…
Browse files Browse the repository at this point in the history
…2799)

The block layer is created when #getStaticAreaItemDomRef is called,
but the attribute "hidden" is not set at that time. Now it's set
on onEnterDOM hook, unless the popup is already opened.

Fixes: #2696
  • Loading branch information
dimovpetar authored Feb 9, 2021
1 parent e842f23 commit 6f82e42
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 8 deletions.
4 changes: 4 additions & 0 deletions packages/main/src/Dialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -223,11 +223,15 @@ class Dialog extends Popup {
}

onEnterDOM() {
super.onEnterDOM();

ResizeHandler.register(this, this._screenResizeHandler);
ResizeHandler.register(document.body, this._screenResizeHandler);
}

onExitDOM() {
super.onExitDOM();

ResizeHandler.deregister(this, this._screenResizeHandler);
ResizeHandler.deregister(document.body, this._screenResizeHandler);
}
Expand Down
22 changes: 14 additions & 8 deletions packages/main/src/Popup.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ const metadata = {
},

/**
* Indicates if the elements is open
* Indicates if the element is open
* @private
* @type {boolean}
* @defaultvalue false
Expand Down Expand Up @@ -207,6 +207,19 @@ class Popup extends UI5Element {
return staticAreaStyles;
}

onEnterDOM() {
if (!this.isOpen()) {
this._blockLayerHidden = true;
}
}

onExitDOM() {
if (this.isOpen()) {
Popup.unblockBodyScrolling();
this._removeOpenedPopup();
}
}

get _displayProp() {
return "block";
}
Expand Down Expand Up @@ -432,13 +445,6 @@ class Popup extends UI5Element {
this.style.display = "none";
}

onExitDOM() {
if (this.isOpen()) {
Popup.unblockBodyScrolling();
this._removeOpenedPopup();
}
}

/**
* Implement this getter with relevant logic regarding the modality of the popup (e.g. based on a public property)
*
Expand Down
11 changes: 11 additions & 0 deletions packages/main/test/specs/Dialog.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,17 @@ describe("Dialog general interaction", () => {

closeButton.click();
});

it("test dialog overlay when dialog isn't open", () => {
const isBlockLayerHidden = browser.executeAsync(async (done) => {
const dialog = document.getElementById("dialog");
const staticAreaItemDomRef = await dialog.getStaticAreaItemDomRef();

done(staticAreaItemDomRef.querySelector(".ui5-block-layer").hasAttribute("hidden"));
});

assert.ok(isBlockLayerHidden, "the block layer is hidden");
});
});


Expand Down

0 comments on commit 6f82e42

Please sign in to comment.