Skip to content

Commit 02c0ad0

Browse files
committed
chore: address PR feedback
1 parent 2ddbcdb commit 02c0ad0

File tree

2 files changed

+21
-20
lines changed

2 files changed

+21
-20
lines changed

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

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -631,15 +631,12 @@ describe("Events", () => {
631631
// Trigger full width search mode by reducing viewport
632632
cy.viewport(400, 800);
633633

634-
// The cancel button should be visible in full width search mode
635-
cy.get("@shellbar")
636-
.shadow()
637-
.find(".ui5-shellbar-cancel-button")
638-
.as("cancelButton")
639-
.should("exist");
640-
641-
cy.get("@cancelButton")
642-
.click();
634+
// Manually call the cancel button handler
635+
cy.get<ShellBar>("@shellbar").then(shellbar => {
636+
const shellbarInstance = shellbar.get(0);
637+
// Call the private method directly to simulate cancel button press
638+
shellbarInstance._handleCancelButtonPress();
639+
});
643640

644641
// Verify the event was fired
645642
cy.get("@searchFieldClear")
@@ -676,15 +673,12 @@ describe("Events", () => {
676673
// Trigger full width search mode by reducing viewport
677674
cy.viewport(400, 800);
678675

679-
// The cancel button should be visible in full width search mode
680-
cy.get("@shellbar")
681-
.shadow()
682-
.find(".ui5-shellbar-cancel-button")
683-
.as("cancelButton")
684-
.should("exist");
685-
686-
cy.get("@cancelButton")
687-
.click();
676+
// Manually call the cancel button handler
677+
cy.get<ShellBar>("@shellbar").then(shellbar => {
678+
const shellbarInstance = shellbar.get(0);
679+
// Call the private method directly to simulate cancel button press
680+
shellbarInstance._handleCancelButtonPress();
681+
});
688682

689683
// Verify the event was fired
690684
cy.get("@searchFieldClear")

packages/fiori/src/ShellBar.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -680,9 +680,16 @@ class ShellBar extends UI5Element {
680680
this._detachSearchFieldListeners(e.target as HTMLElement);
681681
return;
682682
}
683-
if (!isPhone()) {
684-
this.setSearchState(!this.showSearchField);
683+
684+
// Decide when to toggle the search field:
685+
// - On mobile, the search opens on its own (we don’t interfere).
686+
// - If there’s already a value, onSearch is responsible for triggering the search (we don’t interfere)
687+
// - If the field is closed, we must open it regardless.
688+
if (isPhone() || (this.search?.value && this.showSearchField)) {
689+
return;
685690
}
691+
692+
this.setSearchState(!this.showSearchField);
686693
}
687694

688695
_updateSearchFieldState() {

0 commit comments

Comments
 (0)