Skip to content

Commit fd9f6ed

Browse files
authored
fix: DatePicker update data when currentTs change (#360)
1 parent 4409667 commit fd9f6ed

File tree

3 files changed

+17
-8
lines changed

3 files changed

+17
-8
lines changed

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,10 @@
5757
"@testing-library/user-event": "^12.0.0",
5858
"@types/estree": "^1.0.0",
5959
"@types/jest": "^26.0.24",
60-
"@types/lodash.debounce": "^4.0.6",
61-
"@types/lodash.throttle": "^4.1.6",
60+
"@types/babel__traverse": "7.14.0",
61+
"@types/lodash": "4.14.168",
6262
"@types/marked": "^4.0.3",
63-
"@types/node": "^17.0.41",
63+
"@types/node": "17.0.41",
6464
"@types/react": "^16.9.23",
6565
"@types/react-dom": "^16.9.5",
6666
"@types/react-router-dom": "^5.1.3",

packages/arcodesign/components/date-picker/index.tsx

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
1+
import type { Ref } from 'react';
12
import React, {
23
useEffect,
34
useRef,
45
useState,
56
useMemo,
67
forwardRef,
7-
Ref,
88
useImperativeHandle,
99
} from 'react';
1010
import { cls, componentWrapper, formatDateNumber, isEmptyValue } from '@arco-design/mobile-utils';
11-
import Picker, { PickerRef } from '../picker';
12-
import { PickerData, ValueType } from '../picker-view';
11+
import type { PickerRef } from '../picker';
12+
import Picker from '../picker';
13+
import type { PickerData, ValueType } from '../picker-view';
1314
import { ContextLayout } from '../context-provider';
1415
import { convertTsToDateObj, oneOf, judgeObj, convertObjToTs } from './helper';
15-
import { ItemType, IDateObj, DatePickerProps } from './type';
16+
import type { ItemType, IDateObj, DatePickerProps } from './type';
1617

1718
export * from './type';
1819

@@ -441,6 +442,14 @@ const DatePicker = forwardRef((props: DatePickerProps, ref: Ref<DatePickerRef>)
441442
_updateRangeValue(currentTs);
442443
}, [currentTs]);
443444

445+
useEffect(() => {
446+
setCurrentTs(
447+
isRange
448+
? Math.min(maxTs, Math.max(minTs, userSetCurrentTs[0]))
449+
: Math.min(maxTs, Math.max(minTs, userSetCurrentTs as number)),
450+
);
451+
}, [userSetCurrentTs, maxTs, minTs, isRange]);
452+
444453
useEffect(() => {
445454
if (visible) {
446455
// 初始化当前时间

packages/arcodesign/components/form/form-item.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
/* eslint-disable react/no-unused-class-component-methods */
2+
import type { ReactNode, Ref } from 'react';
23
import React, {
34
forwardRef,
45
PureComponent,
@@ -7,7 +8,6 @@ import React, {
78
useRef,
89
useState,
910
} from 'react';
10-
import type { ReactNode, Ref } from 'react';
1111
import { cls, Validator, ValidatorType } from '@arco-design/mobile-utils';
1212
import type { ValidatorError } from '@arco-design/mobile-utils';
1313
import { Promise as ES6Promise } from 'es6-promise';

0 commit comments

Comments
 (0)