Add null-safety check for groupedContainers in Docker component

Fix 'Cannot read properties of undefined (reading some)' error by
adding safety check before calling .some() on groupedContainers.

The error occurred when groupedContainers() returned undefined in edge
cases, causing .some() to fail. Now explicitly checking for truthy
value and non-empty array before calling .some().
This commit is contained in:
rcourtman
2025-10-08 09:03:50 +00:00
parent 6a71a3dda1
commit 75fdf4441e
@@ -507,7 +507,10 @@ export const DockerHosts: Component<DockerHostsProps> = (props) => {
.filter((group) => group.containers.length > 0);
});
const hasContainers = createMemo(() => groupedContainers().some(g => g.containers.length > 0));
const hasContainers = createMemo(() => {
const groups = groupedContainers();
return groups && groups.length > 0 && groups.some(g => g.containers.length > 0);
});
const toggleHostSelection = (hostId: string) => {
setSelectedHostId((current) => (current === hostId ? null : hostId));