From 6d7f571c1dc7fd1c63736bb1fc40c2300600cbc6 Mon Sep 17 00:00:00 2001 From: afc163 Date: Thu, 25 Feb 2016 12:04:58 +0800 Subject: [PATCH] Add allowClear and Fix clear button in disabled mode --- components/cascader/index.jsx | 5 +++-- components/cascader/index.md | 1 + 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/components/cascader/index.jsx b/components/cascader/index.jsx index e5dcced45c..183a68d969 100644 --- a/components/cascader/index.jsx +++ b/components/cascader/index.jsx @@ -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) ? : null; @@ -105,6 +105,7 @@ AntCascader.defaultProps = { return label.join(' / '); }, disabled: false, + allowClear: true, onPopupVisibleChange() {}, }; diff --git a/components/cascader/index.md b/components/cascader/index.md index 03d3cde144..3d5462ecbc 100644 --- a/components/cascader/index.md +++ b/components/cascader/index.md @@ -35,3 +35,4 @@ | placeholder | 输入框占位文本 | string | '请选择' | | size | 输入框大小,可选 `large` `default` `small` | string | `default` | | disabled | 禁用 | boolean | false | +| allowClear | 是否支持清除 | boolean | true |