diff --git a/src/components/Dropdown/Dropdown.jsx b/src/components/Dropdown/Dropdown.jsx
index d453427c36ed..5b56b0e7e0f5 100644
--- a/src/components/Dropdown/Dropdown.jsx
+++ b/src/components/Dropdown/Dropdown.jsx
@@ -6,32 +6,59 @@ export default class Dropdown extends React.Component {
active: false
};
+ componentDidMount() {
+ document.addEventListener('keyup', (e) => {
+ if (e.key === "Escape" && this.state.active) {
+ this.setState({ active: false}, () => {
+ this.dropdownButton.focus();
+ });
+ }
+ });
+
+ document.addEventListener('focus', e => {
+ if (!this.dropdown.contains(e.target)) {
+ this.setState({ active: false });
+ }
+ }, true);
+ }
+
render() {
let { className = '', items = [] } = this.props;
let activeMod = this.state.active ? "dropdown__list--active" : "";
return (
-
this.dropdown = el }
onMouseOver={ this._toggle.bind(this, true) }
- onMouseLeave={ this._toggle.bind(this, false) }>
-

- {/* Commented out until media breakpoints are in place
-
{ items[0].title } */}
-
-
+ onMouseLeave={ this._toggle.bind(this, false) }
+ >
+
-
+
);
}
+ _handleArrowKeys(currentIndex, lastIndex, e) {
+ if (["ArrowDown", "ArrowUp"].includes(e.key)) {
+ e.preventDefault();
+ }
+
+ let newIndex = currentIndex;
+ if (e.key === "ArrowDown") {
+ newIndex++;
+ if (newIndex > lastIndex) {
+ newIndex = 0;
+ }
+ }
+
+ if (e.key === "ArrowUp") {
+ newIndex--;
+ if (newIndex < 0) {
+ newIndex = lastIndex;
+ }
+ }
+
+ this.links[newIndex].focus();
+ }
+
+ _handleClick(e) {
+ this.setState({active: true}, () => {
+ this.links[0].focus();
+ });
+ }
+
/**
* Toggle visibility of dropdown items
*
diff --git a/src/components/Dropdown/Dropdown.scss b/src/components/Dropdown/Dropdown.scss
index 0cf9c2bc3551..98b52f1ab8db 100644
--- a/src/components/Dropdown/Dropdown.scss
+++ b/src/components/Dropdown/Dropdown.scss
@@ -2,8 +2,16 @@
.dropdown {
position: relative;
- color: #fff;
- cursor: pointer;
+
+ button {
+ cursor: pointer;
+ color: #fff;
+ border: none;
+ background-color: transparent;
+ margin: 0;
+ padding: 0;
+ font-size: inherit;
+ }
}
.dropdown__language {
diff --git a/src/components/Navigation/Navigation.jsx b/src/components/Navigation/Navigation.jsx
index e9b2862c91f6..15627edb6e6c 100644
--- a/src/components/Navigation/Navigation.jsx
+++ b/src/components/Navigation/Navigation.jsx
@@ -68,8 +68,8 @@ export default class Navigation extends React.Component {