浏览代码

fix: 修复 timepicker 设置为 undefined 是无反应的问题, resolve #918 (#1007)

小丞同学 3 年之前
父节点
当前提交
914e002fc0
共有 1 个文件被更改,包括 18 次插入19 次删除
  1. 18 19
      packages/semi-foundation/timePicker/foundation.ts

+ 18 - 19
packages/semi-foundation/timePicker/foundation.ts

@@ -203,27 +203,26 @@ class TimePickerFoundation<P = Record<string, any>, S = Record<string, any>> ext
 
     refreshProps(props: any = {}) {
         const { value, timeZone, __prevTimeZone } = props;
-        if (!isNullOrUndefined(value)) {
-            let dates = this.parseValue(value);
-            const invalid = this.validateDates(dates);
-
-            if (!invalid) {
-                if (this.isValidTimeZone(timeZone)) {
-                    dates = dates.map(date =>
-                        utcToZonedTime(
-                            this.isValidTimeZone(__prevTimeZone) ? zonedTimeToUtc(date, __prevTimeZone) : date,
-                            timeZone
-                        )
-                    );
-                }
-                const inputValue = this.formatValue(dates);
+        
+        let dates = this.parseValue(value);
+        const invalid = this.validateDates(dates);
 
-                this.setState({
-                    value: dates,
-                    invalid,
-                    inputValue,
-                } as any);
+        if (!invalid) {
+            if (this.isValidTimeZone(timeZone)) {
+                dates = dates.map(date =>
+                    utcToZonedTime(
+                        this.isValidTimeZone(__prevTimeZone) ? zonedTimeToUtc(date, __prevTimeZone) : date,
+                        timeZone
+                    )
+                );
             }
+            const inputValue = this.formatValue(dates);
+
+            this.setState({
+                value: dates,
+                invalid,
+                inputValue,
+            } as any);
         }
     }