mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-06 15:59:52 +03:00
fix window positioning
This commit is contained in:
@@ -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
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
|
|||||||
Reference in New Issue
Block a user