Skip to content

Commit

Permalink
Bugfix (#512)
Browse files Browse the repository at this point in the history
* Bump versions

* Bug fixes
  • Loading branch information
e1emeb0t authored Jul 25, 2017
1 parent 663ab36 commit 7f4f912
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 27 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "element-react",
"version": "1.1.1",
"version": "1.1.2",
"description": "Element UI for React",
"private": false,
"main": "dist/npm/es5/index.js",
Expand Down
39 changes: 22 additions & 17 deletions src/input-number/InputNumber.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export default class InputNumber extends Component {

componentWillReceiveProps(props: Object) {
if (props.value != this.props.value) {
this.setState({ value: props.value });
this.setState({ value: Number(props.value) });
}
}

Expand All @@ -45,20 +45,24 @@ export default class InputNumber extends Component {
}

onBlur(): void {
let value = parseFloat(this.state.value);
let value = this.state.value;

if (isNaN(value)) {
value = ''
} else if (value > this.props.max) {
value = this.props.max;
if (value > this.props.max) {
value = Number(this.props.max);
} else if (value < this.props.min) {
value = this.props.min;
value = Number(this.props.min);
}

this.setState({ value }, this.onChange);
}

onInput(value: mixed): void {
value = Number(value);

if (isNaN(value)) {
return;
}

this.setState({ value });
}

Expand All @@ -69,18 +73,18 @@ export default class InputNumber extends Component {
}

minDisabled(): boolean {
return this.state.value - this.props.step < this.props.min;
return this.state.value - Number(this.props.step) < this.props.min;
}

maxDisabled(): boolean {
return this.state.value + this.props.step > this.props.max;
return this.state.value + Number(this.props.step) > this.props.max;
}

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

if (value + step > max || disabled) return;
if (value + Number(step) > max || disabled) return;

value = accAdd(step, value);

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

if (value - step < min || disabled) return;
if (value - Number(step) < min || disabled) return;

value = accSub(value, step);

Expand Down Expand Up @@ -123,10 +127,11 @@ export default class InputNumber extends Component {
}

render(): React.Element<any> {
const { controls, disabled } = this.props;
const { controls, disabled, size } = this.props;
const { value, inputActive } = this.state;

return (
<div style={this.style()} className={this.className('el-input-number', this.props.size && `el-input-number--${this.props.size}`, {
<div style={this.style()} className={this.className('el-input-number', size && `el-input-number--${size}`, {
'is-disabled': disabled,
'is-without-controls': !controls
})}>
Expand Down Expand Up @@ -157,11 +162,11 @@ export default class InputNumber extends Component {
<Input
ref="input"
className={this.classNames({
'is-active': this.state.inputActive
'is-active': inputActive
})}
value={this.state.value}
disabled={this.props.disabled}
size={this.props.size}
value={value}
disabled={disabled}
size={size}
onChange={this.onInput.bind(this)}
onKeyDown={this.onKeyDown.bind(this)}
onBlur={this.onBlur.bind(this)} />
Expand Down
2 changes: 1 addition & 1 deletion src/menu/Menu.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export default class Menu extends Component {
}

componentWillReceiveProps(props: Object) {
if (props.defaultActive != this.props.defaultActive) {
if (props.defaultActive != this.props.defaultActive || props.defaultActive != this.state.activeIndex) {
this.defaultActiveChanged(props.defaultActive);
}

Expand Down
18 changes: 10 additions & 8 deletions src/select/Select.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -685,16 +685,18 @@ class Select extends Component {
deleteSelected(e: Object) {
e.stopPropagation();

this.setState({
selected: {},
selectedLabel: '',
visible: false
});

if (this.props.onChange) {
this.props.onChange('');
if (this.state.selectedLabel != '') {
this.setState({
selected: {},
selectedLabel: '',
visible: false
});

this.context.form && this.context.form.onFieldChange();

if (this.props.onChange) {
this.props.onChange('');
}
}
}

Expand Down

0 comments on commit 7f4f912

Please sign in to comment.