From 56ad3c353f49771fff4a3628bade87b8b8f02b6c Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 24 Jul 2026 09:58:41 +0000 Subject: [PATCH] Fix overlapping header rows in attendance table The two sticky header rows (dates/lesson-info, then column labels) both anchored to top:0, so once scrolled they collided instead of stacking - the shorter column-labels row would render on top of the taller row above it, which then bled into the first student row. The first row's height varies with which optional fields are shown, so it's measured at runtime and used as the second row's sticky top offset. --- .../reports/in-lesson-report/StudentList.jsx | 28 ++++++++++++++++--- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/client/src/reports/in-lesson-report/StudentList.jsx b/client/src/reports/in-lesson-report/StudentList.jsx index 3bed3b42..693d65af 100644 --- a/client/src/reports/in-lesson-report/StudentList.jsx +++ b/client/src/reports/in-lesson-report/StudentList.jsx @@ -1,4 +1,4 @@ -import React, { useCallback, useContext, useMemo } from 'react'; +import React, { useCallback, useContext, useMemo, useRef, useState, useLayoutEffect } from 'react'; import { NumberInput, DateInput, @@ -35,6 +35,24 @@ export const StudentList = ({ reportDates, setReportDates }) => { const hasPerDateLessonCountPermission = useIsPerDateLessonCount(); const today = useMemo(() => new Date().toISOString().split('T')[0], []); + // The date/lesson-info header row has variable height (permission-gated fields, + // date wrapping), so the column-labels row below it needs its sticky `top` measured + // at runtime - a static offset would drift out of sync and the two rows would overlap. + const firstHeaderRowRef = useRef(null); + const [firstHeaderRowHeight, setFirstHeaderRowHeight] = useState(0); + + useLayoutEffect(() => { + const node = firstHeaderRowRef.current; + if (!node || typeof ResizeObserver === 'undefined') { + return undefined; + } + const updateHeight = () => setFirstHeaderRowHeight(node.getBoundingClientRect().height); + updateHeight(); + const observer = new ResizeObserver(updateHeight); + observer.observe(node); + return () => observer.disconnect(); + }, []); + const columns = useMemo(() => { const cols = []; if (gradeMode) { @@ -79,7 +97,7 @@ export const StudentList = ({ reportDates, setReportDates }) => { - + @@ -146,12 +164,14 @@ export const StudentList = ({ reportDates, setReportDates }) => { ))} - + שם התלמידה {reportDates.map((date, index) => columns.map((column) => ( - + {column.label} )),