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} )),