Skip to content

Commit 5ab3029

Browse files
committed
Apply styles to menu open
1 parent 8faac7f commit 5ab3029

File tree

2 files changed

+18
-22
lines changed

2 files changed

+18
-22
lines changed

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

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Component } from "@angular/core";
1+
import { Component, ElementRef } from "@angular/core";
22

33
/**
44
* The OverFlow menu component encapsulates the OverFlowMenu directive, and the menu iconography into one convienent component
@@ -18,6 +18,7 @@ import { Component } from "@angular/core";
1818
<div
1919
[ibmOverflowMenu]="options"
2020
[appendToBody]="true"
21+
[ngClass]="{'bx--overflow-menu--open': open === true}"
2122
attr.aria-label="{{'OVERFLOW_MENU.OVERFLOW' | translate}}"
2223
class="bx--overflow-menu"
2324
role="button"
@@ -35,6 +36,20 @@ import { Component } from "@angular/core";
3536
<ng-template #options>
3637
<ng-content></ng-content>
3738
</ng-template>
38-
`
39+
`,
40+
styles: [`
41+
.bx--overflow-menu--open {
42+
opacity: 1
43+
}
44+
`]
3945
})
40-
export class OverflowMenu {}
46+
export class OverflowMenu {
47+
constructor(private elementRef: ElementRef) {}
48+
49+
get open() {
50+
if (this.elementRef.nativeElement.children[0].getAttribute("aria-expanded") === "true") {
51+
return true;
52+
}
53+
return false;
54+
}
55+
}

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

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -51,25 +51,6 @@ export class OverflowMenuDirective extends DialogDirective {
5151

5252
onDialogInit() {
5353
this.dialogConfig.content = this.ibmOverflowMenu;
54-
this.dialogService.isClosed.subscribe(() => this.updateOpacity());
55-
}
56-
57-
open() {
58-
super.open();
59-
this.updateOpacity();
60-
}
61-
62-
toggle() {
63-
super.toggle();
64-
this.updateOpacity();
65-
}
66-
67-
updateOpacity() {
68-
if (this.elementRef.nativeElement.getAttribute("aria-expanded") === "true") {
69-
this.elementRef.nativeElement.style.opacity = 1;
70-
} else {
71-
this.elementRef.nativeElement.style.opacity = null;
72-
}
7354
}
7455

7556
@HostListener("keydown", ["$event"])

0 commit comments

Comments
 (0)