Skip to content

Commit bcc505f

Browse files
fix: allow tooltip disabled icon button (#3062)
Co-authored-by: Akshat Patel <[email protected]>
1 parent bda34f7 commit bcc505f

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

src/button/icon-button.component.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import { ButtonSize, ButtonType } from "./button.types";
2727
<cds-tooltip
2828
class="cds--icon-tooltip"
2929
[description]="description"
30-
[disabled]="disabled"
30+
[disabled]="showTooltipWhenDisabled ? false : disabled"
3131
[caret]="caret"
3232
[dropShadow]="dropShadow"
3333
[highContrast]="highContrast"
@@ -123,6 +123,10 @@ export class IconButton extends BaseIconButton implements AfterViewInit {
123123
* The string or template content to be exposed by the tooltip.
124124
*/
125125
@Input() description: string | TemplateRef<any>;
126+
/**
127+
* Indicates whether the tooltip should be shown when the button is disabled
128+
*/
129+
@Input() showTooltipWhenDisabled = false;
126130

127131
/**
128132
* Common button events

src/button/icon-button.stories.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ export default {
2323
size: "md",
2424
isExpressive: "false",
2525
disabled: false,
26-
autoAlign: false
26+
autoAlign: false,
27+
showTooltipWhenDisabled: false
2728
},
2829
argTypes: {
2930
align: {
@@ -54,6 +55,9 @@ export default {
5455
disabled: {
5556
type: "boolean"
5657
},
58+
showTooltipWhenDisabled: {
59+
type: "boolean"
60+
},
5761
// Actions
5862
onClick: { action: "clicked" },
5963
onMouseEnter: { action: "mouseenter" },
@@ -79,6 +83,7 @@ const Template = (args) => ({
7983
[buttonNgClass]="buttonNgClass"
8084
[buttonAttributes]="buttonAttributes"
8185
[disabled]="disabled"
86+
[showTooltipWhenDisabled]="showTooltipWhenDisabled"
8287
description="Icon Description"
8388
(click)="onClick($event)"
8489
(mouseenter)="onMouseEnter($event)"
@@ -115,6 +120,7 @@ const AutoAlignTemplate = (args) => ({
115120
[isOpen]="isOpen"
116121
[buttonNgClass]="buttonNgClass"
117122
[disabled]="disabled"
123+
[showTooltipWhenDisabled]="showTooltipWhenDisabled"
118124
[description]="description"
119125
(click)="onClick($event)"
120126
(mouseenter)="onMouseEnter($event)"
@@ -134,3 +140,4 @@ WithAutoAlign.args = {
134140
align: "top",
135141
isOpen: true
136142
};
143+

0 commit comments

Comments
 (0)