Skip to content

Commit b392d46

Browse files
authored
fix(ui5-dynamic-page): correct pin button tooltip based on pinned state (#12086)
The pin button tooltip now correctly displays: - "Pin Header" when header is not pinned - "Unpin Header" when header is pinned Previously, the tooltip always showed "Pin Header" regardless of the current pinned state, which was confusing for users. Fixes: #12064
1 parent 50fd58d commit b392d46

File tree

3 files changed

+41
-1
lines changed

3 files changed

+41
-1
lines changed

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

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,38 @@ describe("DynamicPage", () => {
3535
.invoke("prop", "headerPinned")
3636
.should("be.false");
3737
});
38+
39+
it("should show correct tooltip for pin button based on pinned state", () => {
40+
// Initially the header should not be pinned, so tooltip should be "Pin Header"
41+
cy.get("@dynamicPage")
42+
.shadow()
43+
.find("ui5-dynamic-page-header-actions")
44+
.shadow()
45+
.find(".ui5-dynamic-page-header-action-pin")
46+
.should("have.attr", "tooltip", "Pin Header");
47+
48+
// Pin the header
49+
cy.get("@dynamicPage")
50+
.invoke("prop", "headerPinned", true);
51+
52+
// After pinning, tooltip should change to "Unpin Header"
53+
cy.get("@dynamicPage")
54+
.shadow()
55+
.find("ui5-dynamic-page-header-actions")
56+
.shadow()
57+
.find(".ui5-dynamic-page-header-action-pin")
58+
.should("have.attr", "tooltip", "Unpin Header");
59+
60+
// Unpin the header
61+
cy.get("@dynamicPage")
62+
.invoke("prop", "headerPinned", false);
63+
64+
// After unpinning, tooltip should change back to "Pin Header"
65+
cy.get("@dynamicPage")
66+
.shadow()
67+
.find("ui5-dynamic-page-header-actions")
68+
.shadow()
69+
.find(".ui5-dynamic-page-header-action-pin")
70+
.should("have.attr", "tooltip", "Pin Header");
71+
});
3872
});

packages/fiori/src/DynamicPageHeaderActions.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import {
2626
DYNAMIC_PAGE_ARIA_LABEL_EXPAND_HEADER,
2727
DYNAMIC_PAGE_ARIA_LABEL_SNAP_HEADER,
2828
DYNAMIC_PAGE_ARIA_LABEL_PIN_HEADER,
29+
DYNAMIC_PAGE_ARIA_LABEL_UNPIN_HEADER,
2930
} from "./generated/i18n/i18n-defaults.js";
3031

3132
type DynamicPageHeaderActionsAccessibilityAttributes = Pick<AccessibilityAttributes, "controls">;
@@ -153,7 +154,9 @@ class DynamicPageHeaderActions extends UI5Element {
153154
}
154155

155156
get pinLabel() {
156-
return DynamicPageHeaderActions.i18nBundle.getText(DYNAMIC_PAGE_ARIA_LABEL_PIN_HEADER);
157+
return this.pinned
158+
? DynamicPageHeaderActions.i18nBundle.getText(DYNAMIC_PAGE_ARIA_LABEL_UNPIN_HEADER)
159+
: DynamicPageHeaderActions.i18nBundle.getText(DYNAMIC_PAGE_ARIA_LABEL_PIN_HEADER);
157160
}
158161

159162
get expandLabel() {

packages/fiori/src/i18n/messagebundle.properties

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ DYNAMIC_PAGE_ARIA_LABEL_SNAP_HEADER=Snap Header
2323
#XACT: Aria label for the button that pins the header
2424
DYNAMIC_PAGE_ARIA_LABEL_PIN_HEADER=Pin Header
2525

26+
#XACT: Aria label for the button that unpins the header
27+
DYNAMIC_PAGE_ARIA_LABEL_UNPIN_HEADER=Unpin Header
28+
2629
#XACT: Aria description for the button that toggles the header
2730
DYNAMIC_PAGE_ARIA_DESCR_TOGGLE_HEADER=Toggle Header
2831

0 commit comments

Comments
 (0)