提交 31ee4bea 编写于 作者: A afc163

Fix textarea not editable bug, close #646

Caused by #589 fix

and fix #586 via https://github.com/facebook/react/issues/2533#issuecomment-15150334
上级 69dc8e5f
import React from 'react';
import assign from 'object-assign';
function prefixClsFn(prefixCls, ...args) {
return args.map((s)=> {
......@@ -14,6 +15,13 @@ function ieGT9() {
return documentMode > 9;
}
function fixControlledValue(value) {
if (typeof value === 'undefined' || value === null) {
return '';
}
return value;
}
class Group extends React.Component {
render() {
const className = 'ant-input-group ' + (this.props.className || '');
......@@ -57,7 +65,7 @@ class Input extends React.Component {
}
renderInput() {
const props = this.props;
const props = assign({}, this.props);
const prefixCls = props.prefixCls;
let inputClassName = prefixClsFn(prefixCls, 'input');
if (!props.type) {
......@@ -73,9 +81,12 @@ class Input extends React.Component {
if(placeholder && ieGT9()){
placeholder = null;
}
if ('value' in props) {
props.value = fixControlledValue(props.value);
}
switch (props.type) {
case 'textarea':
return <textarea {...props} value={props.value || props.defaultValue} placeholder={placeholder} className={inputClassName} ref="input" />;
return <textarea {...props} placeholder={placeholder} className={inputClassName} ref="input" />;
default:
inputClassName = props.className ? props.className : inputClassName;
return <input {...props} placeholder={placeholder} className={inputClassName} ref="input"/>;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册