Skip to content

Commit

Permalink
fix inpunt-item parttern bug #334
Browse files Browse the repository at this point in the history
  • Loading branch information
pingan1927 committed Oct 8, 2016
1 parent a106851 commit e2b1d43
Showing 1 changed file with 19 additions and 12 deletions.
31 changes: 19 additions & 12 deletions components/input-item/index.web.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -134,17 +134,6 @@ export default class InputItem extends React.Component<InputItemProps, InputItem
prefixCls, prefixListCls, type, value, defaultValue, name, editable, disabled, style, clear, children,
error, className, extra, labelNumber, maxLength } = this.props;

let valueProps;
if (value !== undefined) {
valueProps = {
value: fixControlledValue(value),
};
} else {
valueProps = {
defaultValue,
};
}

const { focus, placeholder } = this.state;
const wrapCls = classNames({
[`${prefixListCls}-item`]: true,
Expand Down Expand Up @@ -172,6 +161,24 @@ export default class InputItem extends React.Component<InputItemProps, InputItem
inputType = 'password';
}

let valueProps;
if (value !== undefined) {
valueProps = {
value: fixControlledValue(value),
};
} else {
valueProps = {
defaultValue,
};
}

let patternProps;
if (type === 'number') {
patternProps = {
pattern: '[0-9]*',
}
}

return (
<div className={wrapCls} style={style}>
{children ? (<div className={labelCls}>{children}</div>) : null}
Expand All @@ -187,7 +194,7 @@ export default class InputItem extends React.Component<InputItemProps, InputItem
onFocus={this.onInputFocus}
readOnly={!editable}
disabled={disabled}
pattern={type === 'number' ? '[0-9]*' : ''}
{...patternProps}
/>
</div>
{clear && editable && !disabled && (value && value.length > 0) ?
Expand Down

0 comments on commit e2b1d43

Please sign in to comment.