From 4f4240227e0f91fe46fc1af734282f10a5279f78 Mon Sep 17 00:00:00 2001 From: afc163 Date: Tue, 8 Dec 2015 19:18:04 +0800 Subject: [PATCH] Fix textarea not editable bug, close #646 Caused by #589 fix and fix #586 via https://github.com/facebook/react/issues/2533#issuecomment-15150334 --- components/input/index.jsx | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/components/input/index.jsx b/components/input/index.jsx index 6094923abe..a5c56a496b 100644 --- a/components/input/index.jsx +++ b/components/input/index.jsx @@ -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