Merge pull request #3849 from 2betop/fix-input-date

fix: 修复 inputDate 显示值不同步的问题
This commit is contained in:
hsm-lv 2022-03-24 21:26:04 +08:00 committed by GitHub
commit f5741401e3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -371,18 +371,7 @@ export class DatePicker extends React.Component<DateProps, DatePickerState> {
value: normalizeValue(props.value, props.format)
};
if (
typeof prevValue === 'undefined' || // initApi 的情况
(typeof prevValue === 'string' && // 公式的情况
(prevValue.startsWith('+') ||
prevValue.startsWith('-') ||
prevValue.startsWith('$')))
) {
newState.inputValue =
normalizeValue(this.props.value, this.props.format)?.format(
this.props.inputFormat
) || '';
}
newState.inputValue = newState.value.format(this.props.inputFormat) || '';
this.setState(newState);
}