Skip to content

Commit 9f0d907

Browse files
authored
fix(ui5-button): adjust tooltips display (#11268)
Issue: - The default icon tooltip is displayed over the ui5-button even though there is a text in the ui5-button's slot. Solution: - The default icon tooltip should only be shown when the ui5-button is in icon-only mode according to the UX guidelines. Fixes: #10824
1 parent 985eba7 commit 9f0d907

File tree

4 files changed

+11
-6
lines changed

4 files changed

+11
-6
lines changed

packages/main/cypress/specs/Button.cy.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,13 @@ describe("Accessibility", () => {
238238
.should("have.attr", "title", "Download");
239239
});
240240

241+
it("tooltip not displayed when there is a text", () => {
242+
cy.mount(<Button icon="home">Action</Button>);
243+
244+
cy.get("[ui5-button]")
245+
.should("not.have.attr", "title");
246+
});
247+
241248
it("aria-expanded is properly applied on the button tag", () => {
242249
cy.mount(<Button icon="home" design="Emphasized">Action Bar Button</Button>);
243250

packages/main/src/Button.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,8 @@ class Button extends UI5Element implements IButton {
367367
this.hasEndIcon = !!this.endIcon;
368368
this.iconOnly = this.isIconOnly;
369369

370-
this.buttonTitle = this.tooltip || await this.getDefaultTooltip();
370+
const defaultTooltip = await this.getDefaultTooltip();
371+
this.buttonTitle = this.iconOnly ? this.tooltip ?? defaultTooltip : this.tooltip;
371372
}
372373

373374
_setBadgeOverlayStyle() {
@@ -514,10 +515,6 @@ class Button extends UI5Element implements IButton {
514515
return this.nonInteractive ? -1 : Number.parseInt(this.forcedTabIndex);
515516
}
516517

517-
get showIconTooltip() {
518-
return getEnableDefaultTooltips() && this.iconOnly && !this.tooltip;
519-
}
520-
521518
get ariaLabelText() {
522519
return getEffectiveAriaLabelText(this);
523520
}

packages/main/src/ButtonTemplate.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ export default function ButtonTemplate(this: Button, injectedProps?: {
4848
name={this.icon}
4949
mode="Decorative"
5050
part="icon"
51-
showTooltip={this.showIconTooltip}
5251
/>
5352
}
5453

packages/main/test/pages/Button.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
</head>
1919

2020
<body class="button1auto">
21+
<ui5-button design="Negative" icon="decline">Reject</ui5-button>
22+
<ui5-button design="Positive" icon="add">Add</ui5-button>
2123
<ui5-button icon="home" id="icon-only-comment"><!----><!----></ui5-button>
2224
<ui5-button icon="text" id="icon-only-blank-text"> </ui5-button>
2325
<ui5-button accessible-role="Link" id="button-role-link"> Navigation Button </ui5-button>

0 commit comments

Comments
 (0)