mirror of
https://github.com/ant-design/ant-design.git
synced 2025-01-18 14:13:37 +08:00
Fix textarea not editable bug, close #646
Caused by #589 fix and fix #586 via https://github.com/facebook/react/issues/2533#issuecomment-15150334
This commit is contained in:
parent
b95d9ff5ab
commit
4f4240227e
@ -1,4 +1,5 @@
|
||||
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() {
|
||||
return (
|
||||
@ -61,7 +69,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) {
|
||||
@ -77,9 +85,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"/>;
|
||||
|
Loading…
Reference in New Issue
Block a user