Skip to content

Commit 47ce97e

Browse files
committed
feat: wrap overflow menu button in tooltip
Signed-off-by: Akshat Patel <[email protected]>
1 parent 64cac82 commit 47ce97e

File tree

3 files changed

+44
-20
lines changed

3 files changed

+44
-20
lines changed

src/dialog/dialog.module.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ import { PlaceholderModule } from "carbon-components-angular/placeholder";
1717
import { ExperimentalModule } from "carbon-components-angular/experimental";
1818
import { UtilsModule } from "carbon-components-angular/utils";
1919
import { IconModule } from "carbon-components-angular/icon";
20+
import { ButtonModule } from "carbon-components-angular/button";
21+
import { TooltipModule } from "carbon-components-angular/tooltip";
2022

2123
@NgModule({
2224
declarations: [
@@ -44,7 +46,9 @@ import { IconModule } from "carbon-components-angular/icon";
4446
PlaceholderModule,
4547
ExperimentalModule,
4648
UtilsModule,
47-
IconModule
49+
IconModule,
50+
ButtonModule,
51+
TooltipModule
4852
]
4953
})
5054
export class DialogModule {}

src/dialog/overflow-menu/overflow-menu.component.ts

Lines changed: 37 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import {
1010
} from "@angular/core";
1111
import { I18n } from "carbon-components-angular/i18n";
1212
import { OverflowMenuDirective } from "./overflow-menu.directive";
13+
import { BaseIconButton } from "carbon-components-angular/button";
1314

1415
/**
1516
* The OverFlow menu component encapsulates the OverFlowMenu directive, and the menu iconography into one convienent component.
@@ -32,22 +33,36 @@ import { OverflowMenuDirective } from "./overflow-menu.directive";
3233
@Component({
3334
selector: "cds-overflow-menu, ibm-overflow-menu",
3435
template: `
35-
<button
36-
[cdsOverflowMenu]="options"
37-
[ngClass]="{'cds--overflow-menu--open': open}"
38-
class="cds--overflow-menu {{triggerClass}}"
39-
[attr.aria-label]="buttonLabel"
40-
[flip]="flip"
41-
[isOpen]="open"
42-
(isOpenChange)="handleOpenChange($event)"
43-
[offset]="offset"
44-
[wrapperClass]="wrapperClass"
45-
aria-haspopup="true"
46-
class="cds--overflow-menu"
47-
type="button"
48-
[placement]="placement">
49-
<ng-template *ngIf="customTrigger; else defaultIcon" [ngTemplateOutlet]="customTrigger"></ng-template>
50-
</button>
36+
<cds-tooltip
37+
class="cds--icon-tooltip"
38+
[description]="description"
39+
[caret]="caret"
40+
[dropShadow]="dropShadow"
41+
[highContrast]="highContrast"
42+
[isOpen]="isOpen"
43+
[align]="align"
44+
[autoAlign]="autoAlign"
45+
[enterDelayMs]="enterDelayMs"
46+
[leaveDelayMs]="leaveDelayMs">
47+
<button
48+
cdsButton="ghost"
49+
[cdsOverflowMenu]="options"
50+
[ngClass]="{'cds--overflow-menu--open': open}"
51+
class="cds--overflow-menu {{triggerClass}}"
52+
[iconOnly]="true"
53+
[attr.aria-label]="buttonLabel"
54+
[flip]="flip"
55+
[isOpen]="open"
56+
(isOpenChange)="handleOpenChange($event)"
57+
[offset]="offset"
58+
[wrapperClass]="wrapperClass"
59+
aria-haspopup="true"
60+
type="button"
61+
[placement]="placement">
62+
<ng-template *ngIf="customTrigger; else defaultIcon" [ngTemplateOutlet]="customTrigger"></ng-template>
63+
</button>
64+
</cds-tooltip>
65+
5166
<ng-template #options>
5267
<ng-content></ng-content>
5368
</ng-template>
@@ -74,9 +89,11 @@ import { OverflowMenuDirective } from "./overflow-menu.directive";
7489
`],
7590
encapsulation: ViewEncapsulation.None
7691
})
77-
export class OverflowMenu {
92+
export class OverflowMenu extends BaseIconButton {
7893
@Input() buttonLabel = this.i18n.get().OVERFLOW_MENU.OVERFLOW;
7994

95+
@Input() description = this.i18n.get().OVERFLOW_MENU.ICON_DESCRIPTION;
96+
8097
@Input() flip = false;
8198

8299
@Input() placement: "bottom" | "top" = "bottom";
@@ -103,7 +120,9 @@ export class OverflowMenu {
103120

104121
@ContentChild(OverflowMenuDirective) overflowMenuDirective: OverflowMenuDirective;
105122

106-
constructor(protected elementRef: ElementRef, protected i18n: I18n) {}
123+
constructor(protected elementRef: ElementRef, protected i18n: I18n) {
124+
super();
125+
}
107126

108127
handleOpenChange(event: boolean) {
109128
this.open = event;

src/i18n/en.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@ export default {
5555
"DECREMENT": "Decrement value"
5656
},
5757
"OVERFLOW_MENU": {
58-
"OVERFLOW": "Overflow"
58+
"OVERFLOW": "Overflow",
59+
"ICON_DESCRIPTION": "Options"
5960
},
6061
"SEARCH": {
6162
"LABEL": "Search",

0 commit comments

Comments
 (0)