From ea6a84d9cfbaeb44a4e2e7d683d8727834757d4c Mon Sep 17 00:00:00 2001 From: afc163 Date: Thu, 20 Oct 2016 22:11:55 +0800 Subject: [PATCH] fix DatePicker[showTime] onChange, close #3523 --- components/date-picker/createPicker.tsx | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/components/date-picker/createPicker.tsx b/components/date-picker/createPicker.tsx index 3562cf2355..0aa8b7dfd8 100644 --- a/components/date-picker/createPicker.tsx +++ b/components/date-picker/createPicker.tsx @@ -4,6 +4,7 @@ import MonthCalendar from 'rc-calendar/lib/MonthCalendar'; import RcDatePicker from 'rc-calendar/lib/Picker'; import classNames from 'classnames'; import assign from 'object-assign'; +import omit from 'omit.js'; import Icon from '../icon'; export interface PickerProps { @@ -51,7 +52,7 @@ export default function createPicker(TheCalendar) { }, render() { - const props = this.props; + const props = omit(this.props, ['onChange']); const prefixCls = props.prefixCls; const locale = props.locale; @@ -72,9 +73,9 @@ export default function createPicker(TheCalendar) { let calendarHandler: Object = { onOk: this.handleChange, // fix https://github.com/ant-design/ant-design/issues/1902 - onSelect: (value) => { - if (!('value' in this.props)) { - this.setState({ value }); + onSelect: (value, cause) => { + if (cause && cause.source === 'todayButton') { + this.handleChange(value); } }, };