Skip to content

Commit

Permalink
fix(ui5-popover): fix infinite open/show loop (#9055)
Browse files Browse the repository at this point in the history
fixes #9031
  • Loading branch information
TeodorTaushanov committed May 29, 2024
1 parent 3e2b32e commit a142caf
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 3 deletions.
3 changes: 2 additions & 1 deletion packages/main/src/Popover.ts
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ class Popover extends Popup {
this._show();
}

_show() {
async _show() {
super._show();

if (!this._opened) {
Expand Down Expand Up @@ -396,6 +396,7 @@ class Popover extends Popup {
}

if (this._preventRepositionAndClose || this.isOpenerOutsideViewport(this._openerRect!)) {
await this._waitForDomRef();
return this.closePopup();
}

Expand Down
4 changes: 2 additions & 2 deletions packages/main/src/ResponsivePopover.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,9 @@ class ResponsivePopover extends Popover {
}
}

_show() {
async _show() {
if (!isPhone()) {
super._show();
return super._show();
}
}

Expand Down
23 changes: 23 additions & 0 deletions packages/main/test/specs/ComboBox.mobile.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,29 @@ describe("Basic mobile picker rendering and interaction", () => {

const dialogInput = await browser.$(`#placeholder_test`).shadow$("ui5-responsive-popover").$("[ui5-input]");
assert.strictEqual(await dialogInput.getAttribute("placeholder"), await combo.getAttribute("placeholder"), "Correct placeholder shown");

// close the suggestions
await browser.keys("Escape");
});

it("Should open and close the mobile picker with value state", async () => {
const comboBoxError = await browser.$("#value-state-error");

await comboBoxError.scrollIntoView();
await comboBoxError.click();

const dialogInput = await comboBoxError.shadow$("ui5-responsive-popover").$("[ui5-input]").shadow$("input");
await dialogInput.click();
await dialogInput.keys("A");

const popover = await comboBoxError.shadow$("ui5-responsive-popover");
assert.ok(await popover.hasAttribute("open"), "Suggestions are open");

// clear the input
await dialogInput.keys("Escape");
// close the suggestions
await browser.keys("Escape");
assert.notOk(await popover.hasAttribute("open"), "Suggestions are closed");
});
});

Expand Down

0 comments on commit a142caf

Please sign in to comment.