diff --git a/packages/fiori/cypress/specs/DynamicPage.cy.tsx b/packages/fiori/cypress/specs/DynamicPage.cy.tsx index 9fc6b28a869f..d3bfd3dc60f1 100644 --- a/packages/fiori/cypress/specs/DynamicPage.cy.tsx +++ b/packages/fiori/cypress/specs/DynamicPage.cy.tsx @@ -305,6 +305,160 @@ describe("DynamicPage", () => { cy.get("[data-testid='bottom-input']").should("be.visible"); }); + + it("does not scroll content when a button is clicked while the header is partially hidden", () => { + let clickCount = 0; + + cy.mount( + + +
Page Title
+
+ +
+
Line 1
+
Line 2
+
Line 3
+
Line 4
+
Rack: 34
+
+
+ +
+
+ ); + + cy.get("[ui5-dynamic-page]") + .shadow() + .find(".ui5-dynamic-page-scroll-container") + .then(($container) => { + $container[0].scrollTop = 120; + }); + + cy.get("[ui5-dynamic-page]") + .shadow() + .find(".ui5-dynamic-page-scroll-container") + .then(($container) => { + const initialScrollTop = $container[0].scrollTop; + + cy.get("[data-testid='content-button']") + .realClick(); + + cy.then(() => { + expect(clickCount).to.equal(1); + }); + + cy.get("[ui5-dynamic-page]") + .shadow() + .find(".ui5-dynamic-page-scroll-container") + .should(($updatedContainer) => { + expect($updatedContainer[0].scrollTop).to.be.closeTo(initialScrollTop, 1); + }); + }); + }); + + it("does not scroll content when a visible button receives keyboard focus while the header is partially hidden", () => { + cy.mount( + + +
Page Title
+
+ +
+
Line 1
+
Line 2
+
Line 3
+
Line 4
+
Rack: 34
+
+
+ + +
+
+ ); + + cy.get("[ui5-dynamic-page]") + .shadow() + .find(".ui5-dynamic-page-scroll-container") + .then(($container) => { + $container[0].scrollTop = 120; + }); + + cy.get("[data-testid='first-content-button']") + .focus() + .should("be.focused"); + + cy.get("[ui5-dynamic-page]") + .shadow() + .find(".ui5-dynamic-page-scroll-container") + .then(($container) => { + const initialScrollTop = $container[0].scrollTop; + + cy.realPress("Tab"); + + cy.get("[data-testid='content-button']") + .should("be.focused"); + + cy.get("[ui5-dynamic-page]") + .shadow() + .find(".ui5-dynamic-page-scroll-container") + .should(($updatedContainer) => { + expect($updatedContainer[0].scrollTop).to.be.closeTo(initialScrollTop, 1); + }); + }); + }); + + it("scrolls a partially clipped textarea into view when focused via Tab", () => { + cy.mount( + + +
Page Title
+
+ +
+
Line 1
+
Line 2
+
Line 3
+
Line 4
+
Rack: 34
+
+
+ +