Skip to content

Commit ec9c4ad

Browse files
NgChiKinzombieJ
andauthored
fix: shows current week as selected in correct year (#313)
* fix: shows current week as selected in correct year * test: add test case --------- Co-authored-by: 二货机器人 <smith3816@gmail.com>
1 parent c377ca0 commit ec9c4ad

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

src/utils/dateUtil.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ export function isSameWeek<DateType>(
125125
}
126126

127127
return (
128+
isSameYear(generateConfig, date1!, date2!) &&
128129
generateConfig.locale.getWeek(locale, date1!) === generateConfig.locale.getWeek(locale, date2!)
129130
);
130131
}

tests/panel.spec.tsx

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -682,4 +682,18 @@ describe('Picker.Panel', () => {
682682
expect(container).toMatchSnapshot();
683683
});
684684
});
685+
686+
it('week picker current should check year', () => {
687+
const { container } = render(
688+
<MomentPickerPanel picker="week" value={getMoment('1990-09-03')} />,
689+
);
690+
expect(
691+
container.querySelector('.rc-picker-week-panel-row-selected td[title="1990-09-03"]'),
692+
).toBeTruthy();
693+
694+
// Diff year
695+
fireEvent.click(container.querySelector('.rc-picker-header-super-next-btn'));
696+
expect(container.querySelector('td[title="1991-09-03"]')).toBeTruthy();
697+
expect(container.querySelector('.rc-picker-week-panel-row-selected')).toBeFalsy();
698+
});
685699
});

0 commit comments

Comments
 (0)