Skip to content

Commit 7f4f912

Browse files
authored
Bugfix (#512)
* Bump versions * Bug fixes
1 parent 663ab36 commit 7f4f912

File tree

4 files changed

+34
-27
lines changed

4 files changed

+34
-27
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "element-react",
3-
"version": "1.1.1",
3+
"version": "1.1.2",
44
"description": "Element UI for React",
55
"private": false,
66
"main": "dist/npm/es5/index.js",

src/input-number/InputNumber.jsx

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export default class InputNumber extends Component {
2525

2626
componentWillReceiveProps(props: Object) {
2727
if (props.value != this.props.value) {
28-
this.setState({ value: props.value });
28+
this.setState({ value: Number(props.value) });
2929
}
3030
}
3131

@@ -45,20 +45,24 @@ export default class InputNumber extends Component {
4545
}
4646

4747
onBlur(): void {
48-
let value = parseFloat(this.state.value);
48+
let value = this.state.value;
4949

50-
if (isNaN(value)) {
51-
value = ''
52-
} else if (value > this.props.max) {
53-
value = this.props.max;
50+
if (value > this.props.max) {
51+
value = Number(this.props.max);
5452
} else if (value < this.props.min) {
55-
value = this.props.min;
53+
value = Number(this.props.min);
5654
}
5755

5856
this.setState({ value }, this.onChange);
5957
}
6058

6159
onInput(value: mixed): void {
60+
value = Number(value);
61+
62+
if (isNaN(value)) {
63+
return;
64+
}
65+
6266
this.setState({ value });
6367
}
6468

@@ -69,18 +73,18 @@ export default class InputNumber extends Component {
6973
}
7074

7175
minDisabled(): boolean {
72-
return this.state.value - this.props.step < this.props.min;
76+
return this.state.value - Number(this.props.step) < this.props.min;
7377
}
7478

7579
maxDisabled(): boolean {
76-
return this.state.value + this.props.step > this.props.max;
80+
return this.state.value + Number(this.props.step) > this.props.max;
7781
}
7882

7983
increase(): void {
8084
const { step, max, disabled } = this.props;
8185
let { value, inputActive } = this.state;
8286

83-
if (value + step > max || disabled) return;
87+
if (value + Number(step) > max || disabled) return;
8488

8589
value = accAdd(step, value);
8690

@@ -95,7 +99,7 @@ export default class InputNumber extends Component {
9599
const { step, min, disabled } = this.props;
96100
let { value, inputActive } = this.state;
97101

98-
if (value - step < min || disabled) return;
102+
if (value - Number(step) < min || disabled) return;
99103

100104
value = accSub(value, step);
101105

@@ -123,10 +127,11 @@ export default class InputNumber extends Component {
123127
}
124128

125129
render(): React.Element<any> {
126-
const { controls, disabled } = this.props;
130+
const { controls, disabled, size } = this.props;
131+
const { value, inputActive } = this.state;
127132

128133
return (
129-
<div style={this.style()} className={this.className('el-input-number', this.props.size && `el-input-number--${this.props.size}`, {
134+
<div style={this.style()} className={this.className('el-input-number', size && `el-input-number--${size}`, {
130135
'is-disabled': disabled,
131136
'is-without-controls': !controls
132137
})}>
@@ -157,11 +162,11 @@ export default class InputNumber extends Component {
157162
<Input
158163
ref="input"
159164
className={this.classNames({
160-
'is-active': this.state.inputActive
165+
'is-active': inputActive
161166
})}
162-
value={this.state.value}
163-
disabled={this.props.disabled}
164-
size={this.props.size}
167+
value={value}
168+
disabled={disabled}
169+
size={size}
165170
onChange={this.onInput.bind(this)}
166171
onKeyDown={this.onKeyDown.bind(this)}
167172
onBlur={this.onBlur.bind(this)} />

src/menu/Menu.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ export default class Menu extends Component {
3838
}
3939

4040
componentWillReceiveProps(props: Object) {
41-
if (props.defaultActive != this.props.defaultActive) {
41+
if (props.defaultActive != this.props.defaultActive || props.defaultActive != this.state.activeIndex) {
4242
this.defaultActiveChanged(props.defaultActive);
4343
}
4444

src/select/Select.jsx

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -685,16 +685,18 @@ class Select extends Component {
685685
deleteSelected(e: Object) {
686686
e.stopPropagation();
687687

688-
this.setState({
689-
selected: {},
690-
selectedLabel: '',
691-
visible: false
692-
});
693-
694-
if (this.props.onChange) {
695-
this.props.onChange('');
688+
if (this.state.selectedLabel != '') {
689+
this.setState({
690+
selected: {},
691+
selectedLabel: '',
692+
visible: false
693+
});
696694

697695
this.context.form && this.context.form.onFieldChange();
696+
697+
if (this.props.onChange) {
698+
this.props.onChange('');
699+
}
698700
}
699701
}
700702

0 commit comments

Comments
 (0)