From 8f68631c047d65d434fd8d37410dac5c43a816f1 Mon Sep 17 00:00:00 2001 From: Nikolay Deshev Date: Fri, 7 Nov 2025 08:06:23 +0200 Subject: [PATCH 1/2] fix(ui5-search): fix popup opening when there are no suggestions fixes: #12519 --- packages/fiori/cypress/specs/Search.cy.tsx | 61 ++++++++++++++++++++++ packages/fiori/src/Search.ts | 2 +- 2 files changed, 62 insertions(+), 1 deletion(-) diff --git a/packages/fiori/cypress/specs/Search.cy.tsx b/packages/fiori/cypress/specs/Search.cy.tsx index d4bcc0c5f069..88908cbb84a3 100644 --- a/packages/fiori/cypress/specs/Search.cy.tsx +++ b/packages/fiori/cypress/specs/Search.cy.tsx @@ -1053,6 +1053,67 @@ describe("Events", () => { .should("not.have.been.called"); }); + it("should not open popover when typing with no items", () => { + cy.mount( + + + ); + + cy.get("[ui5-search]") + .then(search => { + search.get(0).addEventListener("ui5-open", cy.stub().as("opened")); + }); + + cy.get("[ui5-search]") + .shadow() + .find("input") + .realClick(); + + cy.get("[ui5-search]") + .realPress("t"); + + cy.get("[ui5-search]") + .realPress("e"); + + cy.get("[ui5-search]") + .realPress("s"); + + cy.get("[ui5-search]") + .realPress("t"); + + cy.get("@opened") + .should("not.have.been.called"); + + cy.get("[ui5-search]") + .should("not.have.attr", "open"); + }); + + it("should open popover when loading is true even with no items", () => { + cy.mount( + + + ); + + cy.get("[ui5-search]") + .then(search => { + search.get(0).addEventListener("ui5-open", cy.stub().as("opened")); + }); + + cy.get("[ui5-search]") + .shadow() + .find("input") + .realClick(); + + cy.get("[ui5-search]") + .realPress("t"); + + cy.get("@opened") + .should("have.been.calledOnce"); + + cy.get("[ui5-search]") + .should("have.attr", "open"); + }); + it("open event - typing, pressing Escape, then typing again should reopen suggestions", () => { cy.mount( diff --git a/packages/fiori/src/Search.ts b/packages/fiori/src/Search.ts index 76b203e00a29..0c071b508657 100755 --- a/packages/fiori/src/Search.ts +++ b/packages/fiori/src/Search.ts @@ -425,7 +425,7 @@ class Search extends SearchField { } this._isTyping = true; - this.open = this.value.length > 0; + this.open = this.value.length > 0 && this._popoupHasAnyContent(); } _handleClear(): void { From 2ab5fc555c9bfa742e973b408a50e5576dd00f8e Mon Sep 17 00:00:00 2001 From: Nikolay Deshev Date: Fri, 7 Nov 2025 08:13:19 +0200 Subject: [PATCH 2/2] fix(ui5-search): fix popup opening when there are no suggestions adjust event spying in tests --- packages/fiori/cypress/specs/Search.cy.tsx | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/packages/fiori/cypress/specs/Search.cy.tsx b/packages/fiori/cypress/specs/Search.cy.tsx index 88908cbb84a3..f6ba8fa6620e 100644 --- a/packages/fiori/cypress/specs/Search.cy.tsx +++ b/packages/fiori/cypress/specs/Search.cy.tsx @@ -1060,9 +1060,7 @@ describe("Events", () => { ); cy.get("[ui5-search]") - .then(search => { - search.get(0).addEventListener("ui5-open", cy.stub().as("opened")); - }); + .invoke("on", "ui5-open", cy.spy().as("openSpy")); cy.get("[ui5-search]") .shadow() @@ -1081,7 +1079,7 @@ describe("Events", () => { cy.get("[ui5-search]") .realPress("t"); - cy.get("@opened") + cy.get("@openSpy") .should("not.have.been.called"); cy.get("[ui5-search]") @@ -1095,9 +1093,7 @@ describe("Events", () => { ); cy.get("[ui5-search]") - .then(search => { - search.get(0).addEventListener("ui5-open", cy.stub().as("opened")); - }); + .invoke("on", "ui5-open", cy.spy().as("openSpy")); cy.get("[ui5-search]") .shadow() @@ -1107,7 +1103,7 @@ describe("Events", () => { cy.get("[ui5-search]") .realPress("t"); - cy.get("@opened") + cy.get("@openSpy") .should("have.been.calledOnce"); cy.get("[ui5-search]")