Skip to content

Commit 4d4b998

Browse files
committed
simplify overflow-menu-pane and add offset
1 parent 30b35a5 commit 4d4b998

File tree

1 file changed

+24
-12
lines changed

1 file changed

+24
-12
lines changed
Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { Component } from "@angular/core";
22
import { Dialog } from "../dialog.component";
3+
import { position } from "../../utils/position";
34

45
/**
56
* Extend the `Dialog` component to create an overflow menu.
@@ -9,16 +10,27 @@ import { Dialog } from "../dialog.component";
910
@Component({
1011
selector: "ibm-overflow-menu-pane",
1112
template: `
12-
<div #dialog>
13-
<ul
14-
class="bx--overflow-menu-options bx--overflow-menu-options--open"
15-
tabindex="-1">
16-
<ng-template
17-
[ngTemplateOutlet]="dialogConfig.content"
18-
[ngTemplateOutletContext]="{overflowMenu: this}">
19-
</ng-template>
20-
</ul>
21-
</div>
22-
`
13+
<ul
14+
#dialog
15+
class="bx--overflow-menu-options bx--overflow-menu-options--open"
16+
tabindex="-1">
17+
<ng-template
18+
[ngTemplateOutlet]="dialogConfig.content"
19+
[ngTemplateOutletContext]="{overflowMenu: this}">
20+
</ng-template>
21+
</ul>
22+
`
2323
})
24-
export class OverflowMenuPane extends Dialog {}
24+
export class OverflowMenuPane extends Dialog {
25+
onDialogInit() {
26+
/**
27+
* -20 shifts the menu up to compensate for the
28+
* extra offset generated by the wrapper component.
29+
*
30+
* 60 shifts the menu right to align the arrow.
31+
* (position service trys it's best to center everything,
32+
* so we need to add some compensation)
33+
*/
34+
this.addGap["bottom"] = pos => position.addOffset(pos, -20, 60);
35+
}
36+
}

0 commit comments

Comments
 (0)