Add allowClear and Fix clear button in disabled mode

This commit is contained in:
afc163 2016-02-25 12:04:58 +08:00
parent 38a4436599
commit 6d7f571c1d
2 changed files with 4 additions and 2 deletions

View File

@ -51,12 +51,12 @@ class AntCascader extends React.Component {
this.setState({ popupVisible: false });
}
render() {
const { prefixCls, children, placeholder, size, disabled, className } = this.props;
const { prefixCls, children, placeholder, size, disabled, className, allowClear } = this.props;
const sizeCls = classNames({
'ant-input-lg': size === 'large',
'ant-input-sm': size === 'small',
});
const clearIcon = this.state.value.length > 0 ?
const clearIcon = (allowClear && !disabled && this.state.value.length > 0) ?
<Icon type="cross-circle"
className={`${prefixCls}-picker-clear`}
onClick={this.clearSelection} /> : null;
@ -105,6 +105,7 @@ AntCascader.defaultProps = {
return label.join(' / ');
},
disabled: false,
allowClear: true,
onPopupVisibleChange() {},
};

View File

@ -35,3 +35,4 @@
| placeholder | 输入框占位文本 | string | '请选择' |
| size | 输入框大小,可选 `large` `default` `small` | string | `default` |
| disabled | 禁用 | boolean | false |
| allowClear | 是否支持清除 | boolean | true |