Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: allow tooltip disabled icon button #3062

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"
Akshat55 marked this conversation as resolved.
Show resolved Hide resolved
[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
};

Loading