Updated App.jsx with improved chart rendering logi1c

This commit is contained in:
Md. Parvej Hossain 2025-08-01 00:27:55 +06:00
parent bf7c3c8be4
commit c0b902a810

View File

@ -329,7 +329,7 @@ function App() {
setChartError(false); setChartError(false);
}, [selectedStudent]); }, [selectedStudent]);
// Function to handle print // FIXED PRINT FUNCTION - THE KEY CHANGE IS HERE
const handlePrintResult = useCallback(() => { const handlePrintResult = useCallback(() => {
if (!selectedStudent) return; if (!selectedStudent) return;
@ -490,10 +490,11 @@ function App() {
printWindow.document.write(printContent); printWindow.document.write(printContent);
printWindow.document.close(); printWindow.document.close();
// FIXED: Removed the printWindow.close() call that was causing the issue
// Wait for the document to load before printing // Wait for the document to load before printing
printWindow.onload = function() { printWindow.onload = function() {
printWindow.print(); printWindow.print();
printWindow.close(); // DO NOT CLOSE THE WINDOW - Let the user close it when they're done
}; };
}, [selectedStudent]); }, [selectedStudent]);