From f7e480ad53a52287ed4b69fc5d05fc732ab72593 Mon Sep 17 00:00:00 2001 From: Benjy Cui Date: Fri, 28 Oct 2016 10:10:02 +0800 Subject: [PATCH] feat: add DatePicker[allowClear], close: #3618 --- components/date-picker/RangePicker.tsx | 3 ++- components/date-picker/createPicker.tsx | 5 +++-- components/date-picker/index.tsx | 5 +++-- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/components/date-picker/RangePicker.tsx b/components/date-picker/RangePicker.tsx index a664c04909..bcc6693f36 100644 --- a/components/date-picker/RangePicker.tsx +++ b/components/date-picker/RangePicker.tsx @@ -8,6 +8,7 @@ import Icon from '../icon'; export default class RangePicker extends React.Component { static defaultProps = { prefixCls: 'ant-calendar', + allowClear: true, }; constructor(props) { @@ -85,7 +86,7 @@ export default class RangePicker extends React.Component { /> ); - const clearIcon = (!props.disabled && state.value && (state.value[0] || state.value[1])) + const clearIcon = (!props.disabled && props.allowClear && state.value && (state.value[0] || state.value[1])) ? ({ getDefaultProps() { return { prefixCls: 'ant-calendar', + allowClear: true, }; }, @@ -128,7 +129,7 @@ export default function createPicker(TheCalendar) { pickerStyle.width = 180; } - const clearIcon = (!props.disabled && this.state.value) ? + const clearIcon = (!props.disabled && props.allowClear && this.state.value) ? React.ReactNode; - prefixCls?: string; - inputPrefixCls?: string; } export interface SinglePickerProps {