Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(date-range-picker): logical judgment error when start and end values exist at the same time #3301

Merged
merged 1 commit into from
Dec 31, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading