mirror of
https://gitee.com/ant-design/ant-design.git
synced 2024-12-03 04:30:06 +08:00
much better way for #3748 and fix ok close animation
This commit is contained in:
parent
82fa3ed2a5
commit
fc3d320872
@ -60,20 +60,19 @@ export default function createPicker(TheCalendar) {
|
||||
|
||||
// Clear temp value and trigger onChange when hide DatePicker[showTime] panel
|
||||
handleOpenChange(open) {
|
||||
const { showTime, onOpenChange } = this.props;
|
||||
const { showTime, onOpenChange, onChange, format } = this.props;
|
||||
if (!open) {
|
||||
// tricky code to avoid triggering onChange multiple times
|
||||
// when click `Now` button
|
||||
let tempValue;
|
||||
this.setState(prevState => {
|
||||
tempValue = prevState.tempValue;
|
||||
return {
|
||||
tempValue: undefined,
|
||||
};
|
||||
}, () => {
|
||||
const nextState = { tempValue: undefined } as any;
|
||||
if (showTime && tempValue) {
|
||||
this.handleChange(tempValue);
|
||||
nextState.value = tempValue;
|
||||
onChange(tempValue, (tempValue && tempValue.format(format)) || '');
|
||||
}
|
||||
return nextState;
|
||||
});
|
||||
}
|
||||
if (onOpenChange) {
|
||||
|
Loading…
Reference in New Issue
Block a user