fix window positioning

This commit is contained in:
proddy
2025-11-02 19:46:11 +01:00
parent 9f1cd04d45
commit f2e38330ea

View File

@@ -1,4 +1,4 @@
import { memo, useCallback, useEffect, useMemo, useRef, useState } from 'react'; import { memo, useCallback, useEffect, useRef, useState } from 'react';
import { toast } from 'react-toastify'; import { toast } from 'react-toastify';
import DownloadIcon from '@mui/icons-material/GetApp'; import DownloadIcon from '@mui/icons-material/GetApp';
@@ -206,15 +206,14 @@ const SystemLog = () => {
} }
}, [readValue, readOpen, send]); }, [readValue, readOpen, send]);
// Memoize box positioning to avoid recalculating on every render const boxPosition = () => {
const boxPosition = useMemo(() => {
const logWindow = document.getElementById('log-window'); const logWindow = document.getElementById('log-window');
if (!logWindow) { if (!logWindow) {
return { top: 0, left: 0 }; return { top: 0, left: 0 };
} }
const rect = logWindow.getBoundingClientRect(); const rect = logWindow.getBoundingClientRect();
return { top: rect.bottom, left: rect.left }; return { top: rect.bottom, left: rect.left };
}, [data]); // Recalculate only when data changes (settings may affect layout) };
const content = () => { const content = () => {
if (!data) { if (!data) {
@@ -359,8 +358,8 @@ const SystemLog = () => {
position: 'absolute', position: 'absolute',
right: 18, right: 18,
bottom: 18, bottom: 18,
left: boxPosition.left, left: boxPosition().left,
top: boxPosition.top - 110, top: boxPosition().top,
p: 1 p: 1
}} }}
> >