Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(line-ripple): stop calling foundation.setRippleCenter when argument is NaN #287

Merged
merged 1 commit into from
Sep 25, 2018
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
56 changes: 42 additions & 14 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"test:unit": "npm run clean && NODE_ENV=test karma start karma.local.js --single-run",
"test:unit-ci": "karma start karma.ci.js --single-run",
"test:image-diff": "MDC_COMMIT_HASH=$(git rev-parse --short HEAD) MDC_BRANCH_NAME=$(git rev-parse --abbrev-ref HEAD) mocha --compilers js:babel-core/register --ui tdd --timeout 10000 test/screenshot/diff-suite.js",
"test:screenshots": "docker run -it --rm --cap-add=SYS_ADMIN -e MDC_GCLOUD_SERVICE_ACCOUNT_KEY=\"${MDC_GCLOUD_SERVICE_ACCOUNT_KEY}\" mdcreact/screenshots /bin/sh -c 'git checkout master; git pull; npm i; /home/pptruser/material-components-web-react/test/screenshot/start.sh; sleep 200s; npm run test:image-diff'",
"test:screenshots": "docker run -it --rm --cap-add=SYS_ADMIN -e MDC_GCLOUD_SERVICE_ACCOUNT_KEY=\"${MDC_GCLOUD_SERVICE_ACCOUNT_KEY}\" mdcreact/screenshots /bin/sh -c 'git checkout master; git pull; npm i; /home/pptruser/material-components-web-react/test/screenshot/start.sh; sleep 30s; npm run test:image-diff'",
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is to speed up releasing

"upload:screenshots": "node ./test/screenshot/upload-screenshots.js"
},
"config": {
Expand Down
5 changes: 4 additions & 1 deletion packages/line-ripple/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,10 @@ export default class LineRipple extends Component {
this.foundation_.deactivate();
}
}
if (this.props.rippleCenter !== prevProps.rippleCenter) {
// isNaN checks are a temporary fix until MDC Web has fix
// https://github.com/material-components/material-components-web-react/issues/275
// https://github.com/material-components/material-components-web/issues/3643
if (this.props.rippleCenter !== prevProps.rippleCenter && !isNaN(this.props.rippleCenter)) {
this.foundation_.setRippleCenter(this.props.rippleCenter);
}
}
Expand Down
2 changes: 1 addition & 1 deletion test/screenshot/text-field/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';

import TextField, {Input, HelperText} from '../../../packages/text-field';
import TextField, {Input, HelperText} from '../../../packages/text-field/index';
import MaterialIcon from '../../../packages/material-icon/index';

import '../../../packages/floating-label/index.scss';
Expand Down
7 changes: 7 additions & 0 deletions test/unit/line-ripple/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,13 @@ test('#componentDidUpdate when rippleCenter updates it calls ' +
td.verify(wrapper.instance().foundation_.setRippleCenter(10), {times: 1});
});

test('does not call #foundation.setRippleCenter when props.rippleCenter is NaN', () => {
const wrapper = shallow(<LineRipple />);
wrapper.instance().foundation_.setRippleCenter = td.func();
wrapper.setProps({rippleCenter: NaN});
td.verify(wrapper.instance().foundation_.setRippleCenter(td.matchers.anything()), {times: 0});
});

test('#adapter.addClass updates state.classList', () => {
const wrapper = shallow(<LineRipple />);
wrapper.instance().foundation_.adapter_.addClass('test-color-class');
Expand Down