Skip to content

Commit 2e760c6

Browse files
authored
fix(ui5-search): fix popup opening when there are no suggestions (#12640)
* fix(ui5-search): fix popup opening when there are no suggestions fixes: #12519
1 parent 873abf8 commit 2e760c6

File tree

2 files changed

+58
-1
lines changed

2 files changed

+58
-1
lines changed

packages/fiori/cypress/specs/Search.cy.tsx

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1053,6 +1053,63 @@ describe("Events", () => {
10531053
.should("not.have.been.called");
10541054
});
10551055

1056+
it("should not open popover when typing with no items", () => {
1057+
cy.mount(
1058+
<Search>
1059+
</Search>
1060+
);
1061+
1062+
cy.get("[ui5-search]")
1063+
.invoke("on", "ui5-open", cy.spy().as("openSpy"));
1064+
1065+
cy.get("[ui5-search]")
1066+
.shadow()
1067+
.find("input")
1068+
.realClick();
1069+
1070+
cy.get("[ui5-search]")
1071+
.realPress("t");
1072+
1073+
cy.get("[ui5-search]")
1074+
.realPress("e");
1075+
1076+
cy.get("[ui5-search]")
1077+
.realPress("s");
1078+
1079+
cy.get("[ui5-search]")
1080+
.realPress("t");
1081+
1082+
cy.get("@openSpy")
1083+
.should("not.have.been.called");
1084+
1085+
cy.get("[ui5-search]")
1086+
.should("not.have.attr", "open");
1087+
});
1088+
1089+
it("should open popover when loading is true even with no items", () => {
1090+
cy.mount(
1091+
<Search loading={true}>
1092+
</Search>
1093+
);
1094+
1095+
cy.get("[ui5-search]")
1096+
.invoke("on", "ui5-open", cy.spy().as("openSpy"));
1097+
1098+
cy.get("[ui5-search]")
1099+
.shadow()
1100+
.find("input")
1101+
.realClick();
1102+
1103+
cy.get("[ui5-search]")
1104+
.realPress("t");
1105+
1106+
cy.get("@openSpy")
1107+
.should("have.been.calledOnce");
1108+
1109+
cy.get("[ui5-search]")
1110+
.should("have.attr", "open");
1111+
});
1112+
10561113
it("open event - typing, pressing Escape, then typing again should reopen suggestions", () => {
10571114
cy.mount(
10581115
<Search>

packages/fiori/src/Search.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,7 @@ class Search extends SearchField {
425425
}
426426

427427
this._isTyping = true;
428-
this.open = this.value.length > 0;
428+
this.open = this.value.length > 0 && this._popoupHasAnyContent();
429429
}
430430

431431
_handleClear(): void {

0 commit comments

Comments
 (0)