Skip to content

Commit

Permalink
Fix Form onSubmit
Browse files Browse the repository at this point in the history
  • Loading branch information
e1emeb0t committed Aug 28, 2017
1 parent 2f2b821 commit 41ed361
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 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.7",
"version": "1.1.8",
"description": "Element UI for React",
"private": false,
"main": "dist/npm/es5/index.js",
Expand Down
5 changes: 3 additions & 2 deletions src/form/Form.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export default class Form extends Component {
return (
<form style={this.style()} className={this.className('el-form', this.props.labelPosition && `el-form--label-${this.props.labelPosition}`, {
'el-form--inline': this.props.inline
})}>{this.props.children}</form>
})} onSubmit={this.props.onSubmit}>{this.props.children}</form>
)
}
}
Expand All @@ -88,7 +88,8 @@ Form.propTypes = {
labelPosition: PropTypes.oneOf(['right', 'left', 'top']),
labelWidth: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
labelSuffix: PropTypes.string,
inline: PropTypes.bool
inline: PropTypes.bool,
onSubmit: PropTypes.func
}

Form.defaultProps = {
Expand Down
8 changes: 4 additions & 4 deletions src/form/FormItem.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -156,29 +156,29 @@ export default class FormItem extends Component {
});
}

labelStyle(): { width?: number } {
labelStyle(): { width?: number | string } {
const ret = {};

if (this.parent().props.labelPosition === 'top') return ret;

const labelWidth = this.props.labelWidth || this.parent().props.labelWidth;

if (labelWidth) {
ret.width = Number(labelWidth);
ret.width = parseInt(labelWidth);
}

return ret;
}

contentStyle(): { marginLeft?: number } {
contentStyle(): { marginLeft?: number | string } {
const ret = {};

if (this.parent().props.labelPosition === 'top' || this.parent().props.inline) return ret;

const labelWidth = this.props.labelWidth || this.parent().props.labelWidth;

if (labelWidth) {
ret.marginLeft = Number(labelWidth);
ret.marginLeft = parseInt(labelWidth);
}

return ret;
Expand Down

0 comments on commit 41ed361

Please sign in to comment.