diff --git a/packages/fiori/cypress/specs/ShellBar.cy.tsx b/packages/fiori/cypress/specs/ShellBar.cy.tsx index 5527304ed42c..488fd1c7c288 100644 --- a/packages/fiori/cypress/specs/ShellBar.cy.tsx +++ b/packages/fiori/cypress/specs/ShellBar.cy.tsx @@ -24,8 +24,7 @@ describe("Responsiveness", () => { showNotifications={true} showProductSwitch={true} > - {/* */} - Button3 + @@ -198,8 +197,8 @@ describe("Responsiveness", () => { cy.get("@productSwitchIcon").should("be.visible"); }); - it("tests S Breakpoint and overflow 510px", () => { - cy.viewport(510, 1680); + it("tests S Breakpoint and overflow 520px", () => { + cy.viewport(520, 1680); cy.get("@shellbar").should("have.prop", "breakpointSize", "S"); diff --git a/packages/fiori/src/ShellBar.ts b/packages/fiori/src/ShellBar.ts index ef5062c1f654..a8188d5ed463 100644 --- a/packages/fiori/src/ShellBar.ts +++ b/packages/fiori/src/ShellBar.ts @@ -504,7 +504,9 @@ class ShellBar extends UI5Element { _overflowNotifications: string | null; _lastOffsetWidth = 0; _observableContent: Array = []; + _isAnimating: boolean = false; _autoRestoreSearchField = false; + _handleAnimationEndRef = this._handleAnimationEnd.bind(this); _headerPress: () => void; @@ -737,7 +739,9 @@ class ShellBar extends UI5Element { onAfterRendering() { this._lastOffsetWidth = this.offsetWidth; - this._overflowActions(); + if (!this._isAnimating) { + this._overflowActions(); + } this.onInitialRendering(); } @@ -785,7 +789,7 @@ class ShellBar extends UI5Element { _resetItemsVisibility(items: Array) { items.forEach(item => { - item.classList.remove("ui5-shellbar-hidden-button"); + item.classList.contains("ui5-shellbar-hidden-button") && item.classList.remove("ui5-shellbar-hidden-button"); }); } @@ -855,12 +859,33 @@ class ShellBar extends UI5Element { ResizeHandler.deregister(this, this._handleResize); } + _handleAnimationEnd() { + this._overflowActions(); + this._isAnimating = false; + this.searchField[0].removeEventListener("animationend", this._handleAnimationEndRef); + this.shadowRoot!.querySelector("header")!.classList.remove("ui5-shellbar-animating"); + } + + _attachAnimationEndHandlers() { + const searchWrapper = this.shadowRoot!.querySelector(".ui5-shellbar-search-field"); + this._isAnimating = true; + this.shadowRoot!.querySelector("header")!.classList.add("ui5-shellbar-animating"); + searchWrapper?.addEventListener("animationend", this._handleAnimationEndRef); + setTimeout(() => { + if (this._isAnimating) { + this._handleAnimationEnd(); + } + }, RESIZE_THROTTLE_RATE); + } + _handleSearchIconPress() { const searchButtonRef = this.shadowRoot!.querySelector