From eacdde829f033b68c17447f9673750b08017f334 Mon Sep 17 00:00:00 2001
From: ManishMadan2882
Date: Fri, 9 May 2025 20:07:51 +0530
Subject: [PATCH] (fix/logs) abnormal scroll over page
---
frontend/src/settings/Logs.tsx | 79 +++++++++++++++++++---------------
1 file changed, 44 insertions(+), 35 deletions(-)
diff --git a/frontend/src/settings/Logs.tsx b/frontend/src/settings/Logs.tsx
index 50d67b54..74b00a25 100644
--- a/frontend/src/settings/Logs.tsx
+++ b/frontend/src/settings/Logs.tsx
@@ -73,16 +73,11 @@ function LogsTable({ logs, setPage, loading, tableHeader }: LogsTableProps) {
const [openLogId, setOpenLogId] = useState(null);
const handleLogToggle = (logId: string) => {
- if (openLogId && openLogId !== logId) {
- // If a different log is being opened, close the current one
- const currentOpenLog = document.getElementById(
- openLogId,
- ) as HTMLDetailsElement;
- if (currentOpenLog) {
- currentOpenLog.open = false;
- }
+ if (openLogId === logId) {
+ setOpenLogId(null);
+ } else {
+ setOpenLogId(logId);
}
- setOpenLogId(logId);
};
const firstObserver = useCallback((node: HTMLDivElement | null) => {
@@ -116,16 +111,27 @@ function LogsTable({ logs, setPage, loading, tableHeader }: LogsTableProps) {
{tableHeader ? tableHeader : t('settings.logs.tableHeader')}
-
+
{logs?.map((log, index) => {
if (index === logs.length - 1) {
return (
-
+
);
} else
- return
;
+ return (
+
+ );
})}
{loading &&
}
@@ -134,9 +140,11 @@ function LogsTable({ logs, setPage, loading, tableHeader }: LogsTableProps) {
}
function Log({
log,
+ isOpen,
onToggle,
}: {
log: LogData;
+ isOpen: boolean;
onToggle: (id: string) => void;
}) {
const { t } = useTranslation();
@@ -148,20 +156,17 @@ function Log({
const { id, action, timestamp, ...filteredLog } = log;
return (
-
{
- if ((e.target as HTMLDetailsElement).open) {
- onToggle(log.id);
- }
- }}
- >
-
+
+
onToggle(log.id)}
+ className={`flex cursor-pointer flex-row items-start gap-2 p-2 px-4 py-3 text-gray-900 ${
+ isOpen ? 'rounded-t-xl bg-[#F1F1F1] dark:bg-[#1B1B1B]' : ''
+ }`}
+ >
{`${log.timestamp}`}
@@ -174,18 +179,22 @@ function Log({
: log.question}
-
-
-
- {JSON.stringify(filteredLog, null, 2)}
-
-
-
-
-
+ {isOpen && (
+
+
+
+ {JSON.stringify(filteredLog, null, 2)}
+
+
+
+
+
+
+ )}
+
);
}