Skip to content

Commit 43fe1e0

Browse files
authored
fix(ui5-dynamic-page): correct header snap/pin inconsistency at page top (#11098)
Problem: Several issues occurred with the header snap/pin interaction: When the header was pinned and then snapped, it would glitch into an inconsistent state appearing both snapped and unsnapped simultaneously After unpinning a previously pinned header, attempting to snap it would cause the same visual inconsistency Pinned headers that were snapped remained in a pinned state, causing unexpected behavior Solution: Modified the _toggleHeader method to properly detect when a pinned header is being snapped and ensure it unpins automatically. Also improved the onPinClick method to better handle unpinning when at the top of the page by checking the scroll position and updating the showHeaderInStickArea property accordingly. Fixes: #11088
1 parent 4935d2c commit 43fe1e0

File tree

2 files changed

+51
-0
lines changed

2 files changed

+51
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import DynamicPage from "../../src/DynamicPage.js";
2+
import DynamicPageTitle from "../../src/DynamicPageTitle.js";
3+
import DynamicPageHeader from "../../src/DynamicPageHeader.js";
4+
5+
describe("DynamicPage", () => {
6+
beforeEach(() => {
7+
cy.mount(
8+
<DynamicPage id="test-dynamic-page" style="height: 600px;">
9+
<DynamicPageTitle slot="titleArea">
10+
<div slot="heading">Page Title</div>
11+
</DynamicPageTitle>
12+
<DynamicPageHeader slot="headerArea">
13+
<div>Header Content</div>
14+
</DynamicPageHeader>
15+
<div style={{ height: "1000px" }}>
16+
Page content with enough height to enable scrolling
17+
</div>
18+
</DynamicPage>
19+
);
20+
21+
cy.get("#test-dynamic-page").as("dynamicPage");
22+
});
23+
24+
it("should unpin the header when snapping after being pinned", () => {
25+
cy.get("@dynamicPage")
26+
.invoke("prop", "headerPinned", true);
27+
28+
cy.get("@dynamicPage")
29+
.invoke("prop", "headerSnapped", true);
30+
31+
cy.get("@dynamicPage")
32+
.invoke("prop", "headerSnapped", false);
33+
34+
cy.get("@dynamicPage")
35+
.invoke("prop", "headerPinned")
36+
.should("be.false");
37+
});
38+
});

packages/fiori/src/DynamicPage.ts

+13
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,8 @@ class DynamicPage extends UI5Element {
351351
this.headerPinned = !this.headerPinned;
352352
if (this.headerPinned) {
353353
this.showHeaderInStickArea = true;
354+
} else if (this.scrollContainer!.scrollTop === 0) {
355+
this.showHeaderInStickArea = false;
354356
}
355357
this.fireDecoratorEvent("pin-button-toggle");
356358
await renderFinished();
@@ -372,6 +374,17 @@ class DynamicPage extends UI5Element {
372374
const headerHeight = this.dynamicPageHeader?.getBoundingClientRect().height || 0;
373375
const currentScrollTop = this.scrollContainer!.scrollTop;
374376

377+
if (!this._headerSnapped && this.headerPinned) {
378+
this.headerPinned = false;
379+
this.fireDecoratorEvent("pin-button-toggle");
380+
}
381+
382+
if (currentScrollTop <= SCROLL_THRESHOLD) {
383+
this._headerSnapped = !this._headerSnapped;
384+
this.showHeaderInStickArea = this._headerSnapped;
385+
return;
386+
}
387+
375388
if (currentScrollTop > SCROLL_THRESHOLD && currentScrollTop < headerHeight) {
376389
if (!this._headerSnapped) {
377390
this._headerSnapped = true;

0 commit comments

Comments
 (0)