Skip to content

Commit

Permalink
fix: allow tooltip disabled icon button (#3062)
Browse files Browse the repository at this point in the history
Co-authored-by: Akshat Patel <[email protected]>
  • Loading branch information
klaascuvelier and Akshat55 authored Nov 22, 2024
1 parent bda34f7 commit bcc505f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
6 changes: 5 additions & 1 deletion src/button/icon-button.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import { ButtonSize, ButtonType } from "./button.types";
<cds-tooltip
class="cds--icon-tooltip"
[description]="description"
[disabled]="disabled"
[disabled]="showTooltipWhenDisabled ? false : disabled"
[caret]="caret"
[dropShadow]="dropShadow"
[highContrast]="highContrast"
Expand Down Expand Up @@ -123,6 +123,10 @@ export class IconButton extends BaseIconButton implements AfterViewInit {
* The string or template content to be exposed by the tooltip.
*/
@Input() description: string | TemplateRef<any>;
/**
* Indicates whether the tooltip should be shown when the button is disabled
*/
@Input() showTooltipWhenDisabled = false;

/**
* Common button events
Expand Down
9 changes: 8 additions & 1 deletion src/button/icon-button.stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ export default {
size: "md",
isExpressive: "false",
disabled: false,
autoAlign: false
autoAlign: false,
showTooltipWhenDisabled: false
},
argTypes: {
align: {
Expand Down Expand Up @@ -54,6 +55,9 @@ export default {
disabled: {
type: "boolean"
},
showTooltipWhenDisabled: {
type: "boolean"
},
// Actions
onClick: { action: "clicked" },
onMouseEnter: { action: "mouseenter" },
Expand All @@ -79,6 +83,7 @@ const Template = (args) => ({
[buttonNgClass]="buttonNgClass"
[buttonAttributes]="buttonAttributes"
[disabled]="disabled"
[showTooltipWhenDisabled]="showTooltipWhenDisabled"
description="Icon Description"
(click)="onClick($event)"
(mouseenter)="onMouseEnter($event)"
Expand Down Expand Up @@ -115,6 +120,7 @@ const AutoAlignTemplate = (args) => ({
[isOpen]="isOpen"
[buttonNgClass]="buttonNgClass"
[disabled]="disabled"
[showTooltipWhenDisabled]="showTooltipWhenDisabled"
[description]="description"
(click)="onClick($event)"
(mouseenter)="onMouseEnter($event)"
Expand All @@ -134,3 +140,4 @@ WithAutoAlign.args = {
align: "top",
isOpen: true
};

0 comments on commit bcc505f

Please sign in to comment.