mirror of
https://github.com/ant-design/ant-design.git
synced 2024-11-25 03:29:59 +08:00
fix(date-picker): fix focus
This commit is contained in:
parent
1e62802d58
commit
f52b087194
@ -12,6 +12,7 @@ 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;
|
||||
@ -124,6 +125,12 @@ class RangePicker extends React.Component<any, RangePickerState> {
|
||||
};
|
||||
}
|
||||
|
||||
componentDidUpdate(prevProps: PickerProps) {
|
||||
if ('open' in prevProps && prevProps.open) {
|
||||
this.focus();
|
||||
}
|
||||
}
|
||||
|
||||
clearSelection = (e: React.MouseEvent<HTMLElement>) => {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
@ -158,10 +165,6 @@ class RangePicker extends React.Component<any, RangePickerState> {
|
||||
if (onOpenChange) {
|
||||
onOpenChange(open);
|
||||
}
|
||||
|
||||
if (!open) {
|
||||
this.focus();
|
||||
}
|
||||
};
|
||||
|
||||
handleShowDateChange = (showDate: RangePickerValue) => this.setState({ showDate });
|
||||
|
@ -7,6 +7,7 @@ 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)) || '';
|
||||
@ -55,6 +56,12 @@ class WeekPicker extends React.Component<any, WeekPickerState> {
|
||||
};
|
||||
}
|
||||
|
||||
componentDidUpdate(prevProps: PickerProps) {
|
||||
if ('open' in prevProps && prevProps.open) {
|
||||
this.focus();
|
||||
}
|
||||
}
|
||||
|
||||
weekDateRender = (current: any) => {
|
||||
const selectedValue = this.state.value;
|
||||
const { prefixCls } = this;
|
||||
@ -90,10 +97,6 @@ class WeekPicker extends React.Component<any, WeekPickerState> {
|
||||
if (onOpenChange) {
|
||||
onOpenChange(open);
|
||||
}
|
||||
|
||||
if (!open) {
|
||||
this.focus();
|
||||
}
|
||||
};
|
||||
|
||||
clearSelection = (e: React.MouseEvent<HTMLElement>) => {
|
||||
|
@ -70,6 +70,12 @@ export default function createPicker(TheCalendar: React.ComponentClass): any {
|
||||
};
|
||||
}
|
||||
|
||||
componentDidUpdate(prevProps: PickerProps) {
|
||||
if ('open' in prevProps && prevProps.open) {
|
||||
this.focus();
|
||||
}
|
||||
}
|
||||
|
||||
renderFooter = (...args: any[]) => {
|
||||
const { renderExtraFooter } = this.props;
|
||||
const { prefixCls } = this;
|
||||
@ -108,10 +114,6 @@ export default function createPicker(TheCalendar: React.ComponentClass): any {
|
||||
if (onOpenChange) {
|
||||
onOpenChange(open);
|
||||
}
|
||||
|
||||
if (!open) {
|
||||
this.focus();
|
||||
}
|
||||
};
|
||||
|
||||
focus() {
|
||||
|
Loading…
Reference in New Issue
Block a user