Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 4 additions & 10 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@
"dependencies": {
"@babel/runtime": "7.0.0-rc.1",
"classnames": "2.2.6",
"deep-assign": "2.0.0",
"keycode": "2.2.0",
"material-design-icons": "3.0.1",
"react-scrollbar-size": "2.1.0",
"react-transition-group": "1.2.1",
Expand Down Expand Up @@ -85,6 +83,7 @@
"karma-safari-launcher": "1.0.0",
"karma-sourcemap-loader": "0.3.7",
"karma-webpack": "3.0.0",
"keycode": "2.2.0",
"lodash": "4.17.10",
"mocha": "5.2.0",
"npm-run-all": "4.1.3",
Expand Down
7 changes: 4 additions & 3 deletions src/Button/Button.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import {findDOMNode} from 'react-dom';
import keycode from 'keycode';
import makeClass from 'classnames';
import PropTypes from 'prop-types';
import React from 'react';
Expand Down Expand Up @@ -54,9 +53,11 @@ class Button extends React.Component {

onKeyDown = rippleMiddleware(this, 'keyDown', (e, ...args) => {
this.setState({mouseFocused: false});
const key = keycode(e.keyCode);
const {keyCode} = e;
const isEnter = (keyCode === 13);
const isSpace = (keyCode === 32);
const isAnchorTag = findDOMNode(this).tagName === 'A';
if (key === 'enter' || (!isAnchorTag && key === 'space')) {
if (isEnter || (!isAnchorTag && isSpace)) {
e.persist();
this.ripple.remove(e, {}, () => (
this.ripple.add(e, {pulsate: true, centered: true})
Expand Down
8 changes: 5 additions & 3 deletions src/Dialog/Dialog.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,13 @@ describe('Dialog', () => {
assert(wrapper);
});

it('should mount in an open state, then close', () => {
it('should mount in an open state, then close', createTest(() => {
const wrapper = mount(<Dialog open/>);
wrapper.setProps({open: false});
assert(wrapper);
});
setTimeout(() => {
assert(wrapper);
}, 500);
}));

it('should mount in an open state, then close', createTest(() => {
const wrapper = mount(<Dialog
Expand Down
10 changes: 6 additions & 4 deletions src/Dialog/DialogInner.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import keycode from 'keycode';
import makeClass from 'classnames';
import PropTypes from 'prop-types';
import React from 'react';
Expand Down Expand Up @@ -35,8 +34,11 @@ class DialogInner extends React.Component {

onKeyDown(e) {
if (this.props.open) {
const key = keycode(e.keyCode);
if (key === 'tab') {
const {keyCode} = e;
const isTab = (keyCode === 9);
const isEsc = (keyCode === 27);

if (isTab) {
if (this.actions.children.length <= 1) {
e.preventDefault();
} else if (e.shiftKey) {
Expand All @@ -45,7 +47,7 @@ class DialogInner extends React.Component {
this.onForwardTab(e);
}
}
if (key === 'esc') {
if (isEsc) {
this.props.onClose();
}
}
Expand Down
13 changes: 7 additions & 6 deletions src/List/List.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import deepAssign from 'deep-assign';
import keycode from 'keycode';
import makeClass from 'classnames';
import PropTypes from 'prop-types';
import React from 'react';
Expand All @@ -12,10 +10,13 @@ class List extends React.Component {
}

onKeyDown(e, ...args) {
const key = e.keyCode;
if (key === keycode('down') || key === keycode('up')) {
const {keyCode} = e;
const isDown = (keyCode === 40);
const isUp = (keyCode === 38);

if (isDown || isUp) {
e.preventDefault();
const nodeOfInterest = key === keycode('up') ? 'previousElementSibling' : 'nextElementSibling';
const nodeOfInterest = isUp ? 'previousElementSibling' : 'nextElementSibling';
const nextListItem = e.target.parentElement;
if (nextListItem && nextListItem[nodeOfInterest]) {
nextListItem[nodeOfInterest].firstChild.focus();
Expand All @@ -36,7 +37,7 @@ class List extends React.Component {
<div {...other} ref={this.registerRoot} className={makeClass(Styles.root, className)}>
{React.Children.map(children, child => {
const props = {
buttonProps: deepAssign({focusRippleDisabled: true}, child.props.buttonProps)
buttonProps: {...child.props.buttonProps, focusRippleDisabled: true}
};
if (arrowNavigation) {
props.onKeyDown = this.onKeyDown;
Expand Down
9 changes: 5 additions & 4 deletions src/Switch/Switch.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import keycode from 'keycode';
import makeClass from 'classnames';
import PropTypes from 'prop-types';
import React from 'react';
Expand Down Expand Up @@ -27,10 +26,12 @@ class Switch extends React.Component {
this.input.click();
}

onKeyUp(e) {
const key = keycode(e.keyCode);
onKeyUp({keyCode}) {
const isTab = (keyCode === 9);
const isSpace = (keyCode === 32);

this.setState({
keyboardFocused: (key === 'tab' || key === 'space')
keyboardFocused: (isTab || isSpace)
});
}

Expand Down