Skip to content

Commit 85ec88b

Browse files
2 parents 8cb0acf + 3f784b5 commit 85ec88b

18 files changed

+2302
-1896
lines changed

package-lock.json

Lines changed: 2136 additions & 1797 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,6 @@
120120
"karma-sourcemap-loader": "0.3.7",
121121
"karma-spec-reporter": "0.0.32",
122122
"karma-webpack": "3.0.0",
123-
"marked": "0.3.7",
124123
"node-sass": "4.9.0",
125124
"postcss-loader": "2.1.4",
126125
"raw-loader": "0.5.1",

src/button/button.directive.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export class Button implements OnInit {
3030
*/
3131
@Input() size: "normal" | "sm" = "normal";
3232
// a whole lot of HostBindings ... this way we don't have to touch the elementRef directly
33-
@HostBinding("class") btnClass = "bx--btn";
33+
@HostBinding("class.bx--btn") baseClass = true;
3434
@HostBinding("class.bx--btn--primary") primary = true;
3535
@HostBinding("class.bx--btn--secondary") secondary = false;
3636
@HostBinding("class.bx--btn--tertiary") tertiary = false;

src/calendar/month-view/calendar-month.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import {
22
Component,
33
Input,
4-
OnInit,
4+
OnInit
55
} from "@angular/core";
66
import { DateTimeModel } from "./../date-time-model.class";
77
import { range } from "../../common/utils";

src/calendar/months-view/calendar-months.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import {
22
Component,
33
Input,
4-
OnInit,
4+
OnInit
55
} from "@angular/core";
66
import { DateTimeModel } from "./../date-time-model.class";
77
import { range } from "../../common/utils";

src/calendar/quarter-view/calendar-quarter.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { TranslateService } from "@ngx-translate/core";
22
import {
33
Component,
44
Input,
5-
OnInit,
5+
OnInit
66
} from "@angular/core";
77
import { DateTimeModel } from "./../date-time-model.class";
88
import { range } from "../../common/utils";

src/calendar/year-view/calendar-year.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import {
22
Component,
33
Input,
4-
OnInit,
4+
OnInit
55
} from "@angular/core";
66
import { DateTimeModel } from "./../date-time-model.class";
77
import { range } from "../../common/utils";

src/dialog/dialog.component.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,7 @@ export class Dialog implements OnInit, AfterViewInit, OnDestroy {
241241
@HostListener("keydown", ["$event"])
242242
escapeClose(event: KeyboardEvent) {
243243
switch (event.key) {
244+
case "Esc": // IE specific value
244245
case "Escape": {
245246
event.stopImmediatePropagation();
246247
this.doClose();

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

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,8 @@ import {
2222
template: `
2323
<button
2424
class="bx--overflow-menu-options__btn"
25-
[ngClass]="{
26-
'bx--overflow-menu-options__option--danger': type === 'danger',
27-
'bx--overflow-menu-options__option--disabled': disabled
28-
}"
25+
role="menuitem"
26+
[disabled]="disabled"
2927
[tabindex]="(disabled ? -1 : null)"
3028
[title]="(titleEnabled ? content : '')">
3129
<ng-content></ng-content>
@@ -34,8 +32,17 @@ import {
3432
})
3533
export class OverflowMenuOption {
3634
@HostBinding("class") optionClass = "bx--overflow-menu-options__option";
37-
@HostBinding("attr.role") role = "list-item";
35+
@HostBinding("attr.role") role = "presentation";
3836

37+
@HostBinding("class.bx--overflow-menu-options__option--danger")
38+
public get isDanger(): Boolean {
39+
return this.type === "danger";
40+
}
41+
42+
@HostBinding("class.bx--overflow-menu-options__option--disabled")
43+
public get isDisabled(): Boolean {
44+
return this.disabled;
45+
}
3946
/**
4047
* toggles between `normal` and `danger` states
4148
*/

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

Lines changed: 53 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
import { Component } from "@angular/core";
1+
import { Component, ViewChild, HostListener } from "@angular/core";
22
import { Dialog } from "../dialog.component";
33
import { position } from "../../utils/position";
4+
import { isFocusInLastItem, isFocusInFirstItem } from "./../../common/tab.service";
45

56
/**
67
* Extend the `Dialog` component to create an overflow menu.
@@ -11,9 +12,10 @@ import { position } from "../../utils/position";
1112
selector: "ibm-overflow-menu-pane",
1213
template: `
1314
<ul
15+
role="menu"
16+
attr.aria-label="{{'OVERFLOW_MENU.OVERFLOW' | translate}}"
1417
#dialog
15-
class="bx--overflow-menu-options bx--overflow-menu-options--open"
16-
tabindex="-1">
18+
class="bx--overflow-menu-options bx--overflow-menu-options--open">
1719
<ng-template
1820
[ngTemplateOutlet]="dialogConfig.content"
1921
[ngTemplateOutletContext]="{overflowMenu: this}">
@@ -22,6 +24,8 @@ import { position } from "../../utils/position";
2224
`
2325
})
2426
export class OverflowMenuPane extends Dialog {
27+
@ViewChild("dialog") dialog;
28+
2529
onDialogInit() {
2630
/**
2731
* -20 shifts the menu up to compensate for the
@@ -32,5 +36,51 @@ export class OverflowMenuPane extends Dialog {
3236
* so we need to add some compensation)
3337
*/
3438
this.addGap["bottom"] = pos => position.addOffset(pos, -20, 60);
39+
40+
setTimeout(() => this.listItems()[0].focus());
41+
}
42+
43+
@HostListener("keydown", ["$event"])
44+
hostkeys(event: KeyboardEvent) {
45+
this.escapeClose(event);
46+
const listItems = this.listItems();
47+
48+
switch (event.key) {
49+
case "Down": // IE specific value
50+
case "ArrowDown":
51+
event.preventDefault();
52+
if (!isFocusInLastItem(event, listItems)) {
53+
const index = listItems.findIndex(item => item === event.target);
54+
listItems[index + 1].focus();
55+
} else {
56+
listItems[0].focus();
57+
}
58+
break;
59+
60+
case "Up": // IE specific value
61+
case "ArrowUp":
62+
event.preventDefault();
63+
if (!isFocusInFirstItem(event, listItems)) {
64+
const index = listItems.findIndex(item => item === event.target);
65+
listItems[index - 1].focus();
66+
} else {
67+
listItems[listItems.length - 1].focus();
68+
}
69+
break;
70+
71+
case "Home":
72+
event.preventDefault();
73+
listItems[0].focus();
74+
break;
75+
76+
case "End":
77+
event.preventDefault();
78+
listItems[listItems.length - 1].focus();
79+
break;
80+
}
81+
}
82+
83+
private listItems() {
84+
return Array.from<any>(this.dialog.nativeElement.querySelectorAll(".bx--overflow-menu-options__btn:not([disabled])"));
3585
}
3686
}

0 commit comments

Comments
 (0)