From 43aaf03f06f852417f48af55d021a8012ea8ad25 Mon Sep 17 00:00:00 2001 From: Daniel Date: Thu, 16 Jul 2026 19:10:44 +0200 Subject: [PATCH] fix: recompute vacay calendar when week start changes (#1554) --- .../components/Vacay/VacayMonthCard.test.tsx | 17 +++++++++++++++++ client/src/components/Vacay/VacayMonthCard.tsx | 2 +- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/client/src/components/Vacay/VacayMonthCard.test.tsx b/client/src/components/Vacay/VacayMonthCard.test.tsx index 520ce99b9..6d8d8caa1 100644 --- a/client/src/components/Vacay/VacayMonthCard.test.tsx +++ b/client/src/components/Vacay/VacayMonthCard.test.tsx @@ -127,6 +127,23 @@ describe('VacayMonthCard', () => { } }) + it('FE-COMP-VACAYMONTHCARD-013: Recomputes day positions when week start changes', () => { + const { container, rerender } = render() + + const getFirstWeekLabels = () => + Array.from(container.querySelectorAll('.grid.grid-cols-7')[1].children) + .map((cell) => cell.textContent?.trim() || '') + + // January 1, 2025 is Wednesday: two leading blanks for Monday-first weeks. + expect(getFirstWeekLabels()).toEqual(['', '', '1', '2', '3', '4', '5']) + + rerender() + + // Sunday-first weeks need three leading blanks; this must update after the + // setting changes so Saturday/Sunday weekends stay under their real headers. + expect(getFirstWeekLabels()).toEqual(['', '', '', '1', '2', '3', '4']) + }) + it('FE-COMP-VACAYMONTHCARD-011: Two vacation entries render gradient overlay', () => { const props = { ...baseProps, diff --git a/client/src/components/Vacay/VacayMonthCard.tsx b/client/src/components/Vacay/VacayMonthCard.tsx index b48c0fbff..b3e375cf3 100644 --- a/client/src/components/Vacay/VacayMonthCard.tsx +++ b/client/src/components/Vacay/VacayMonthCard.tsx @@ -50,7 +50,7 @@ export default function VacayMonthCard({ const w = [] for (let i = 0; i < cells.length; i += 7) w.push(cells.slice(i, i + 7)) return w - }, [year, month]) + }, [year, month, weekStart]) const pad = (n) => String(n).padStart(2, '0')