Skip to content

Commit

Permalink
Merge pull request DouyinFE#1565 from DouyinFE/fix-1563
Browse files Browse the repository at this point in the history
fix: timepicker rangeType error when select endTime first, close DouyinFE#1563
  • Loading branch information
DaiQiangReal authored Apr 25, 2023
2 parents 3b44c65 + 587be99 commit ec11b9b
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions packages/semi-foundation/timePicker/foundation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
transformToArray,
isTimeFormatLike
} from './utils';
import { split } from 'lodash';
import { split, isUndefined } from 'lodash';
import { isValid, format, getHours } from 'date-fns';
import { utcToZonedTime, zonedTimeToUtc } from '../utils/date-fns-extra';
import isNullOrUndefined from '../utils/isNullOrUndefined';
Expand Down Expand Up @@ -182,7 +182,7 @@ class TimePickerFoundation<P = Record<string, any>, S = Record<string, any>> ext
isAM[index] = panelIsAM;
const inputValue = this.formatValue(value);

if (this.getState('isAM')[index] !== result.isAM){
if (this.getState('isAM')[index] !== result.isAM) {
this.setState({ isAM } as any);
}
if (!this._isControlledComponent('value')) {
Expand Down Expand Up @@ -369,7 +369,16 @@ class TimePickerFoundation<P = Record<string, any>, S = Record<string, any>> ext
}

if (_dates && Array.isArray(_dates)) {
return _dates.map(date => formatToString(date, validFormat, dateFnsLocale)).join(rangeSeparator);
const result = _dates.map(date => {
let str;
if (isUndefined(date)) {
str = '';
} else {
str = formatToString(date, validFormat, dateFnsLocale);
}
return str;
});
return result.join(rangeSeparator);
}
return undefined;
}
Expand Down

0 comments on commit ec11b9b

Please sign in to comment.