Skip to content

Commit a5b8626

Browse files
committed
fix: preserve selected stack log container
1 parent fa788b0 commit a5b8626

1 file changed

Lines changed: 12 additions & 9 deletions

File tree

‎apps/dokploy/components/dashboard/compose/logs/show-stack.tsx‎

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -72,16 +72,19 @@ export const ShowDockerLogsStack = ({
7272
const containers = data?.filter((container) => container.containerId);
7373

7474
useEffect(() => {
75-
if (option === "native") {
76-
if (containers && containers?.length > 0) {
77-
setContainerId(containers[0]?.containerId);
78-
}
79-
} else {
80-
if (services && services?.length > 0) {
81-
setContainerId(services[0]?.containerId);
82-
}
75+
const currentContainers = option === "native" ? containers : services;
76+
77+
if (
78+
currentContainers &&
79+
currentContainers.length > 0 &&
80+
(!containerId ||
81+
!currentContainers.some(
82+
(container) => container.containerId === containerId,
83+
))
84+
) {
85+
setContainerId(currentContainers[0]?.containerId);
8386
}
84-
}, [option, services, containers]);
87+
}, [option, services, containers, containerId]);
8588

8689
const isLoading = option === "native" ? containersLoading : servicesLoading;
8790
const containersLength =

0 commit comments

Comments
 (0)