Skip to content
Open
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
29 changes: 29 additions & 0 deletions packages/fiori/cypress/specs/DynamicPage.cy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,35 @@ describe("DynamicPage", () => {
.should("have.prop", "headerPinned", false);
});

it("renders correctly with initial header-snapped attribute", () => {
cy.mount(
<DynamicPage headerSnapped={true} style={{ height: "600px" }}>
<DynamicPageTitle slot="titleArea">
<div slot="heading">Page Title</div>
<div slot="snappedHeading">Snapped Title</div>
</DynamicPageTitle>
<DynamicPageHeader slot="headerArea">
<div>Header Content</div>
</DynamicPageHeader>
<div style={{ height: "1000px" }}>
Page content with enough height to enable scrolling
</div>
</DynamicPage>
);

cy.get("[ui5-dynamic-page]")
.should("have.prop", "headerSnapped", true);

cy.get("[ui5-dynamic-page-title]")
.should("have.prop", "snapped", true);

cy.get("[ui5-dynamic-page-header]")
.should("have.prop", "_snapped", true);

cy.get("[slot='snappedHeading']")
.should("be.visible");
});

it("toggles the header-snapped state with 'headerSnapped' property", () => {
cy.mount(
<DynamicPage style={{ height: "600px" }}>
Expand Down
12 changes: 10 additions & 2 deletions packages/fiori/src/DynamicPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -292,9 +292,17 @@ class DynamicPage extends UI5Element {
*/
@property({ type: Boolean })
set headerSnapped(snapped: boolean) {
if (snapped !== this._headerSnapped) {
this._toggleHeader();
if (snapped === this._headerSnapped) {
return;
}

if (!this.scrollContainer) {
this._headerSnapped = snapped;
this.showHeaderInStickArea = snapped;
return;
}

this._toggleHeader();
}

snapOnScroll() {
Expand Down
Loading