Skip to content

Commit

Permalink
fix: 修复移动端日期选择完年月无法关闭浮窗的问题 (#9080)
Browse files Browse the repository at this point in the history
* fix: 修复移动端日期选择完年月无法关闭浮窗的问题

* fix: 修复选中日期不展示的问题

* fix: 修复主题配置icon失败问题

* fix: 代码优化

---------

Co-authored-by: hongyang03 <hongyang03@baidu.com>
  • Loading branch information
hy993658052 and hongyang03 authored Jan 2, 2024
1 parent 1c38f80 commit d9ace50
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion packages/amis-ui/src/components/calendar/Calendar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ interface BaseDatePickerProps {
interface BaseDatePickerState {
displayForamt?: boolean | string;
currentView: string;
initView: string;
viewDate: moment.Moment;
selectedDate: moment.Moment;
inputValue?: string;
Expand Down Expand Up @@ -371,6 +372,7 @@ class BaseDatePicker extends React.Component<
state.currentView = this.props.dateFormat
? this.props.viewMode || state.updateOn || 'days'
: this.props.viewMode || 'time';
state.initView = state.currentView;

this.state = state;
this.onClick = this.onClick.bind(this);
Expand Down Expand Up @@ -437,7 +439,6 @@ class BaseDatePicker extends React.Component<
'inputFormat',
'displayForamt',
'onChange',
'onClose',
'requiredConfirm',
'classPrefix',
'prevIcon',
Expand Down Expand Up @@ -691,10 +692,16 @@ class BaseDatePicker extends React.Component<
if (!this.props.value) {
this.setState({
selectedDate: date,
viewDate: date,
inputValue: date!.format(this.state.displayForamt as string)
});
}
this.props.onChange && this.props.onChange(date);
this.onClose();
};

onClose = () => {
this.setState({currentView: this.state.initView});
this.props.onClose && this.props.onClose();
};

Expand Down Expand Up @@ -731,6 +738,7 @@ class BaseDatePicker extends React.Component<
}

viewProps.onConfirm = this.onConfirm;
viewProps.onClose = this.onClose;
viewProps.getDateBoundary = this.getDateBoundary;
viewProps.getColumns = this.getColumns;
viewProps.timeCell = this.timeCell;
Expand Down

0 comments on commit d9ace50

Please sign in to comment.