Skip to content

Commit b8c3c83

Browse files
authored
Merge branch 'master' into AlertModalComponent
2 parents 30cd6cb + ef1035f commit b8c3c83

29 files changed

+142
-58
lines changed

src/button-menu/button-menu-item.component.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ describe("Button Menu", () => {
3535
provide: TranslateLoader, useClass: TranslateFakeLoader
3636
}
3737
})
38-
],
38+
]
3939
});
4040
});
4141

src/checkbox/checkbox.module.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ export { CheckboxComponent } from "./checkbox.component";
1111

1212
@NgModule({
1313
declarations: [
14-
CheckboxComponent,
14+
CheckboxComponent
1515
],
1616
exports: [
17-
CheckboxComponent,
17+
CheckboxComponent
1818
],
1919
imports: [
2020
CommonModule,

src/combobox/combobox.module.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export { ComboBox } from "./combobox.component";
1212

1313
@NgModule({
1414
declarations: [
15-
ComboBox,
15+
ComboBox
1616
],
1717
exports: [
1818
ComboBox,

src/content-switcher/content-switcher.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import { ContentSwitcherOption } from "./content-switcher-option.directive";
2222
role="tablist">
2323
<ng-content></ng-content>
2424
</div>
25-
`,
25+
`
2626
})
2727
export class ContentSwitcher implements AfterViewInit {
2828
@Input() label = "content switcher";

src/content-switcher/content-switcher.stories.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { storiesOf, moduleMetadata } from "@storybook/angular";
2-
import { withNotes } from "@storybook/addon-notes";
32
import { action } from "@storybook/addon-actions";
4-
import { withKnobs, boolean, object } from "@storybook/addon-knobs/angular";
3+
import { withKnobs } from "@storybook/addon-knobs/angular";
54

65
import { ContentSwitcherModule } from "../";
76

@@ -10,7 +9,7 @@ storiesOf("Content Switcher", module)
109
.addDecorator(
1110
moduleMetadata({
1211
imports: [
13-
ContentSwitcherModule,
12+
ContentSwitcherModule
1413
]
1514
})
1615
)

src/dialog/dialog.component.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {
88
OnInit,
99
AfterViewInit,
1010
OnDestroy,
11-
HostListener,
11+
HostListener
1212
} from "@angular/core";
1313
import {
1414
Observable,
@@ -17,7 +17,7 @@ import {
1717
merge
1818
} from "rxjs";
1919
import { throttleTime } from "rxjs/operators";
20-
import position, { AbsolutePosition } from "../utils/position";
20+
import position from "../utils/position";
2121
import { cycleTabs } from "./../common/tab.service";
2222
import { DialogConfig } from "./dialog-config.interface";
2323

@@ -103,7 +103,7 @@ export class Dialog implements OnInit, AfterViewInit, OnDestroy {
103103
"top": pos => position.addOffset(pos, -this.dialogConfig.gap),
104104
"bottom": pos => position.addOffset(pos, this.dialogConfig.gap),
105105
"left-bottom": pos => position.addOffset(pos, 0, -this.dialogConfig.gap),
106-
"right-bottom": pos => position.addOffset(pos, 0, this.dialogConfig.gap),
106+
"right-bottom": pos => position.addOffset(pos, 0, this.dialogConfig.gap)
107107
};
108108

109109
/**
@@ -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/dialog.service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {
55
ComponentFactory,
66
ComponentFactoryResolver,
77
Injectable,
8-
ViewContainerRef,
8+
ViewContainerRef
99
} from "@angular/core";
1010
import { Subscription } from "rxjs";
1111
import { DialogConfig } from "./dialog-config.interface";

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import {
2222
template: `
2323
<button
2424
class="bx--overflow-menu-options__btn"
25+
role="menuitem"
2526
[ngClass]="{
2627
'bx--overflow-menu-options__option--danger': type === 'danger',
2728
'bx--overflow-menu-options__option--disabled': disabled
@@ -34,7 +35,7 @@ import {
3435
})
3536
export class OverflowMenuOption {
3637
@HostBinding("class") optionClass = "bx--overflow-menu-options__option";
37-
@HostBinding("attr.role") role = "list-item";
38+
@HostBinding("attr.role") role = "presentation";
3839

3940
/**
4041
* toggles between `normal` and `danger` states

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

Lines changed: 55 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,53 @@ 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+
const buttonClass = ".bx--overflow-menu-options__btn";
85+
const disabledClass = ".bx--overflow-menu-options__option--disabled";
86+
return Array.from<any>(this.dialog.nativeElement.querySelectorAll(`${buttonClass}:not(${disabledClass})`));
3587
}
3688
}

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,12 @@ import { Component } from "@angular/core";
1818
<div
1919
[ibmOverflowMenu]="options"
2020
[appendToBody]="true"
21-
placement="bottom"
21+
attr.aria-label="{{'OVERFLOW_MENU.OVERFLOW' | translate}}"
2222
class="bx--overflow-menu"
23-
style="display: block;">
23+
role="button"
24+
placement="bottom"
25+
style="display: block;"
26+
tabindex="0">
2427
<svg class="bx--overflow-menu__icon" width="3" height="15" viewBox="0 0 3 15">
2528
<g fill-rule="evenodd">
2629
<circle cx="1.5" cy="1.5" r="1.5" />

0 commit comments

Comments
 (0)