Skip to content

Commit

Permalink
fix(date-range-picker): logical judgment error when start and end val…
Browse files Browse the repository at this point in the history
…ues exist at the same time (#3301)
  • Loading branch information
betavs authored Dec 31, 2024
1 parent 0768c12 commit b735ea8
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/date-picker/DateRangePicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -168,11 +168,11 @@ const DateRangePicker = forwardRef<HTMLDivElement, DateRangePickerProps>((origin
}

// 首次点击不关闭、确保两端都有有效值并且无时间选择器时点击后自动关闭
if (!isFirstValueSelected) {
if (!isFirstValueSelected || !activeIndex) {
let nextIndex = notValidIndex;
if (nextIndex === -1) nextIndex = activeIndex ? 0 : 1;
setActiveIndex(nextIndex);
setIsFirstValueSelected(true);
setIsFirstValueSelected(!!nextValue[0]);
} else {
setPopupVisible(false);
}
Expand Down Expand Up @@ -258,11 +258,11 @@ const DateRangePicker = forwardRef<HTMLDivElement, DateRangePickerProps>((origin
}

// 首次点击不关闭、确保两端都有有效值并且无时间选择器时点击后自动关闭
if (!isFirstValueSelected || nextValue.length === 1) {
if (!isFirstValueSelected || !activeIndex) {
let nextIndex = notValidIndex;
if (nextIndex === -1) nextIndex = activeIndex ? 0 : 1;
setActiveIndex(nextIndex);
setIsFirstValueSelected(true);
setIsFirstValueSelected(!!nextValue[0]);
} else if (nextValue.length === 2) {
setPopupVisible(false);
}
Expand Down

0 comments on commit b735ea8

Please sign in to comment.