fix(date-picker): fix open prop

This commit is contained in:
Yangzhedi 2019-01-04 18:16:15 +08:00 committed by 偏右
parent f52b087194
commit ee1beaa459
3 changed files with 6 additions and 8 deletions

View File

@ -12,7 +12,6 @@ import { ConfigConsumer, ConfigConsumerProps } from '../config-provider';
import warning from '../_util/warning';
import interopDefault from '../_util/interopDefault';
import { RangePickerValue, RangePickerPresetRange } from './interface';
import { PickerProps } from './createPicker';
export interface RangePickerState {
value?: RangePickerValue;
@ -125,8 +124,8 @@ class RangePicker extends React.Component<any, RangePickerState> {
};
}
componentDidUpdate(prevProps: PickerProps) {
if ('open' in prevProps && prevProps.open) {
componentDidUpdate(prevProps: any, prevState: RangePickerState) {
if (!('open' in prevProps) && prevState.open) {
this.focus();
}
}

View File

@ -7,7 +7,6 @@ import classNames from 'classnames';
import Icon from '../icon';
import { ConfigConsumer, ConfigConsumerProps } from '../config-provider';
import interopDefault from '../_util/interopDefault';
import { PickerProps } from './createPicker';
function formatValue(value: moment.Moment | null, format: string): string {
return (value && value.format(format)) || '';
@ -56,8 +55,8 @@ class WeekPicker extends React.Component<any, WeekPickerState> {
};
}
componentDidUpdate(prevProps: PickerProps) {
if ('open' in prevProps && prevProps.open) {
componentDidUpdate(prevProps: any, prevState: WeekPickerState) {
if (!('open' in prevProps) && prevState.open) {
this.focus();
}
}

View File

@ -70,8 +70,8 @@ export default function createPicker(TheCalendar: React.ComponentClass): any {
};
}
componentDidUpdate(prevProps: PickerProps) {
if ('open' in prevProps && prevProps.open) {
componentDidUpdate(prevProps: PickerProps, prevState: PickerState) {
if (!('open' in prevProps) && prevState.open) {
this.focus();
}
}