Skip to content

Commit 88ae405

Browse files
authored
Merge pull request #76 from cal-smith/master
fix(overflow-menu): fix overflow menu not positioning correctly in all cases
2 parents 461ac99 + e4baeee commit 88ae405

File tree

2 files changed

+26
-12
lines changed

2 files changed

+26
-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+
}

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ import { Component } from "@angular/core";
1717
template: `
1818
<div
1919
[ibmOverflowMenu]="options"
20+
[appendToBody]="true"
21+
placement="bottom"
2022
class="bx--overflow-menu"
2123
style="display: block;">
2224
<svg class="bx--overflow-menu__icon" width="3" height="15" viewBox="0 0 3 15">

0 commit comments

Comments
 (0)