Skip to content

Commit b912501

Browse files
eslookviktorvanwijkCharlotte Gieltjes
authored
fix(calendar): fix calendar navigation label (#2996)
Takes over original PR #2993 as they don't have community committer rights. --- Closes #2992 Changed the calendar navigation label to use the calendar year instead of the local week-numbering year --------- Co-authored-by: Viktor van Wijk <viktorvanwijk@hotmail.com> Co-authored-by: Charlotte Gieltjes <charlotte.gieltjes@rebels.io>
1 parent 3be2632 commit b912501

File tree

3 files changed

+16
-1
lines changed

3 files changed

+16
-1
lines changed

.changeset/slimy-dolls-wash.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"@utrecht/calendar-react": patch
3+
"@utrecht/component-library-react": patch
4+
---
5+
6+
Changed the calendar navigation label to use the calendar year instead of the local week-numbering year

packages/components-react/calendar-react/src/index.test.tsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,4 +142,13 @@ describe('Calendar', () => {
142142
if (nextMonthButton) fireEvent.click(nextMonthButton);
143143
expect(currentDateLabel).toContainHTML('april 2023');
144144
});
145+
146+
it('shows correct year in navigation label', () => {
147+
const currentDate = new Date(2025, 11, 29);
148+
const { container } = render(<Calendar onCalendarClick={() => {}} locale={nl} currentDate={currentDate} />);
149+
150+
let currentDateLabel = container.querySelector('.utrecht-calendar__navigation-label');
151+
152+
expect(currentDateLabel).toContainHTML('december 2025');
153+
});
145154
});

packages/components-react/calendar-react/src/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ export const Calendar = ({
147147
onNextClick={() => setVisibleMonth(addMonths(visibleMonth, 1))}
148148
>
149149
<CalendarNavigationLabel dateTime={format(visibleMonth, 'yyyy-mm')}>
150-
{format(visibleMonth, 'LLLL Y', { locale })}
150+
{format(visibleMonth, 'LLLL y', { locale })}
151151
</CalendarNavigationLabel>
152152
</CalendarNavigationButtons>
153153
</CalendarNavigationButtons>

0 commit comments

Comments
 (0)