Skip to content

Commit 4de2083

Browse files
authored
fix(ui5-shellbar-search): fire search on mobile devices on search icon press (#13410)
* fix(ui5-search): fire search on mobile devices on search icon press fire search event when the search icon is pressed in the mobile dialog
1 parent d40fff6 commit 4de2083

2 files changed

Lines changed: 34 additions & 0 deletions

File tree

packages/fiori/cypress/specs/ShellBarSearch.mobile.cy.tsx

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,4 +95,33 @@ describe("Mobile Behaviour", () => {
9595
cy.get("[ui5-shellbar-search]")
9696
.should("have.prop", "collapsed", true);
9797
});
98+
99+
it("should fire search event when search icon is pressed in open dialog", () => {
100+
cy.mount(
101+
<ShellBarSearch showClearIcon={true} onSearch={cy.stub().as("search")}>
102+
<SearchItem text="Item 1" />
103+
<SearchItem text="Item 2" />
104+
</ShellBarSearch>
105+
);
106+
107+
cy.get("[ui5-shellbar-search]")
108+
.shadow()
109+
.find("[ui5-button]")
110+
.realClick();
111+
112+
cy.get("[ui5-shellbar-search]")
113+
.should("have.prop", "open", true);
114+
115+
cy.get("[ui5-shellbar-search]")
116+
.shadow()
117+
.find("[ui5-responsive-popover] header input")
118+
.type("test");
119+
120+
cy.get("[ui5-shellbar-search]")
121+
.shadow()
122+
.find("[ui5-responsive-popover] .ui5-shell-search-field-search-icon")
123+
.realClick();
124+
125+
cy.get("@search").should("have.been.calledOnce");
126+
});
98127
});

packages/fiori/src/ShellBarSearch.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,11 @@ class ShellBarSearch extends Search {
3939
autoOpen = false;
4040

4141
_handleSearchIconPress() {
42+
if (isPhone() && this.open) {
43+
this._handleSearchEvent();
44+
return;
45+
}
46+
4247
super._handleSearchIconPress();
4348

4449
if (this.collapsed) {

0 commit comments

Comments
 (0)