Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 57 additions & 0 deletions packages/fiori/cypress/specs/Search.cy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1053,6 +1053,63 @@ describe("Events", () => {
.should("not.have.been.called");
});

it("should not open popover when typing with no items", () => {
cy.mount(
<Search>
</Search>
);

cy.get("[ui5-search]")
.invoke("on", "ui5-open", cy.spy().as("openSpy"));

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("@openSpy")
.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(
<Search loading={true}>
</Search>
);

cy.get("[ui5-search]")
.invoke("on", "ui5-open", cy.spy().as("openSpy"));

cy.get("[ui5-search]")
.shadow()
.find("input")
.realClick();

cy.get("[ui5-search]")
.realPress("t");

cy.get("@openSpy")
.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(
<Search>
Expand Down
2 changes: 1 addition & 1 deletion packages/fiori/src/Search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Loading