Skip to content

Commit 3a702b7

Browse files
committed
Fixed an bug where RadioButton's onChange() will not be called when wrapping with RadioGroup
1 parent 69cf802 commit 3a702b7

File tree

7 files changed

+91
-72
lines changed

7 files changed

+91
-72
lines changed

dist/react-radio.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/react-radio.min.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/bundle.js

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

docs/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,5 @@
1111
</head>
1212
<body style="background-color: #eee">
1313
<div id="container"></div>
14-
<script type="text/javascript" src="bundle.js?a4a99d36da42386169f8"></script></body>
14+
<script type="text/javascript" src="bundle.js?8f86772f41f9fd6b545b"></script></body>
1515
</html>

examples/RadioGroup.jsx

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,6 @@ export default class extends PureComponent {
1111
};
1212

1313
handleChangeByKey = (key) => (value, event) => {
14-
if (typeof value === 'object' && event === undefined) {
15-
// Prevent onChange propagation
16-
return;
17-
}
18-
1914
this.setState({ [key]: value });
2015
};
2116

package.json

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@trendmicro/react-radio",
3-
"version": "3.1.0",
3+
"version": "3.1.1",
44
"description": "React Radio component",
55
"main": "lib/index.js",
66
"files": [
@@ -29,6 +29,11 @@
2929
"name": "Tina C Lin",
3030
"email": "tina_c_lin@trend.com.tw",
3131
"url": "https://github.com/trendmicro-frontend"
32+
},
33+
{
34+
"name": "Cheton Wu",
35+
"email": "cheton_wu@trend.com.tw",
36+
"url": "https://github.com/trendmicro-frontend"
3237
}
3338
],
3439
"license": "MIT",
@@ -45,16 +50,17 @@
4550
"react": "^0.14.0 || >=15.0.0"
4651
},
4752
"dependencies": {
53+
"chained-function": "^0.5.0",
4854
"classnames": "^2.2.5",
4955
"prop-types": "^15.6.0"
5056
},
5157
"devDependencies": {
5258
"@trendmicro/react-anchor": "~0.5.6",
53-
"@trendmicro/react-buttons": "~1.2.1",
54-
"@trendmicro/react-tooltip": "~0.4.0",
59+
"@trendmicro/react-buttons": "~1.3.0",
60+
"@trendmicro/react-tooltip": "~0.5.0",
5561
"babel-cli": "~6.26.0",
5662
"babel-core": "~6.26.0",
57-
"babel-eslint": "~8.1.2",
63+
"babel-eslint": "~8.2.1",
5864
"babel-loader": "~7.1.2",
5965
"babel-plugin-transform-decorators-legacy": "~1.3.4",
6066
"babel-preset-env": "~1.6.1",
@@ -63,35 +69,35 @@
6369
"clean-css": "~4.1.9",
6470
"clean-css-cli": "~4.1.10",
6571
"coveralls": "~3.0.0",
66-
"css-loader": "~0.28.7",
67-
"enzyme": "~3.2.0",
72+
"css-loader": "~0.28.9",
73+
"enzyme": "~3.3.0",
6874
"enzyme-adapter-react-16": "~1.1.1",
69-
"eslint": "~4.14.0",
75+
"eslint": "~4.17.0",
7076
"eslint-config-trendmicro": "~1.3.0",
7177
"eslint-loader": "~1.9.0",
7278
"eslint-plugin-import": "~2.8.0",
7379
"eslint-plugin-jsx-a11y": "~6.0.3",
74-
"eslint-plugin-react": "~7.5.1",
80+
"eslint-plugin-react": "~7.6.1",
7581
"extract-text-webpack-plugin": "~3.0.2",
7682
"file-loader": "~1.1.6",
7783
"find-imports": "~0.5.2",
7884
"html-webpack-plugin": "~2.30.1",
79-
"http-server": "~0.10.0",
80-
"jsdom": "~11.5.1",
85+
"http-server": "~0.11.1",
86+
"jsdom": "~11.6.2",
8187
"nib": "~1.1.2",
8288
"react": "~16.2.0",
8389
"react-dom": "~16.2.0",
84-
"sinon": "^4.1.3",
85-
"style-loader": "~0.19.1",
86-
"styled-components": "~2.4.0",
90+
"sinon": "^4.3.0",
91+
"style-loader": "~0.20.1",
92+
"styled-components": "~3.1.6",
8793
"stylint": "~1.5.9",
8894
"stylint-loader": "~1.0.0",
8995
"stylus-loader": "~3.0.1",
90-
"tap": "~11.0.1",
96+
"tap": "~11.1.0",
9197
"trendmicro-ui": "~0.5.1",
9298
"url-loader": "~0.6.2",
93-
"webpack": "~3.10.0",
94-
"webpack-dev-server": "~2.9.7",
99+
"webpack": "~3.11.0",
100+
"webpack-dev-server": "~2.11.1",
95101
"which": "~1.3.0"
96102
}
97103
}

src/RadioGroup.jsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import chainedFunction from 'chained-function';
12
import React, { cloneElement, PureComponent } from 'react';
23
import PropTypes from 'prop-types';
34
import RadioButton from './RadioButton';
@@ -14,8 +15,6 @@ class RadioGroup extends PureComponent {
1415
};
1516

1617
handleChange = (value, event) => {
17-
event.stopPropagation();
18-
1918
if (typeof this.props.onChange === 'function') {
2019
this.props.onChange(value, event);
2120
}
@@ -36,7 +35,12 @@ class RadioGroup extends PureComponent {
3635
return cloneElement(child, {
3736
checked: this.props.value === child.props.value,
3837
disabled: this.props.disabled || child.props.disabled,
39-
onChange: this.handleChange.bind(this, child.props.value)
38+
onChange: chainedFunction(
39+
child.props.onChange,
40+
(event) => {
41+
this.handleChange(child.props.value, event);
42+
}
43+
)
4044
});
4145
}
4246

0 commit comments

Comments
 (0)