fix(ui): correct table header alignment glitch caused by checkbox injection

Adds explicit 'align' support to Table headers to override strict index-based alignment. Restores exact center-alignment spacer boxes to Uptime and Infrastructure tables to match develop branch styling.

Fixes #3602
This commit is contained in:
harsh-aghara committed 2026-05-02 14:28:13 +05:30
1 parent ff34c872c8
commit 1b0b17b589
3 files changed
+13 -7

No files matched your search

@@ -36,6 +36,7 @@ export type Header<T> = {
id: number | string; id: number | string;
content: React.ReactNode; content: React.ReactNode;
mobileLabel?: React.ReactNode; mobileLabel?: React.ReactNode;
align?: "left" | "center" | "right" | "justify" | "inherit";
onClick?: (event: React.MouseEvent<HTMLTableCellElement | null>, row: T) => void; onClick?: (event: React.MouseEvent<HTMLTableCellElement | null>, row: T) => void;
render: (row: T) => React.ReactNode; render: (row: T) => React.ReactNode;
}; };
@@ -214,7 +215,7 @@ export function DataTable<
{headers.map((header, idx) => { {headers.map((header, idx) => {
return ( return (
<TableCell <TableCell
align={idx === 0 ? "left" : "center"} align={header.align ?? (idx === 0 ? "left" : "center")}
key={header.id} key={header.id}
> >
{header.content} {header.content}
@@ -243,7 +244,7 @@ export function DataTable<
{headers.map((header, index) => { {headers.map((header, index) => {
return ( return (
<TableCell <TableCell
align={index === 0 ? "left" : "center"} align={header.align ?? (index === 0 ? "left" : "center")}
key={header.id} key={header.id}
onClick={ onClick={
header.onClick ? (e) => header.onClick!(e, row) : undefined header.onClick ? (e) => header.onClick!(e, row) : undefined
@@ -1,4 +1,5 @@
import Box from "@mui/material/Box"; import Box from "@mui/material/Box";
import Stack from "@mui/material/Stack";
import Typography from "@mui/material/Typography"; import Typography from "@mui/material/Typography";
import { Table, Pagination, StatusLabel, Gauge } from "@/Components/design-elements"; import { Table, Pagination, StatusLabel, Gauge } from "@/Components/design-elements";
import type { Header } from "@/Components/design-elements/Table"; import type { Header } from "@/Components/design-elements/Table";
@@ -184,6 +185,7 @@ export const InfraMonitorsTable = ({
}, },
{ {
id: "name", id: "name",
align: "left",
mobileLabel: t("common.table.headers.name"), mobileLabel: t("common.table.headers.name"),
content: ( content: (
<Typography <Typography
@@ -206,17 +208,18 @@ export const InfraMonitorsTable = ({
id: "status", id: "status",
mobileLabel: t("common.table.headers.status"), mobileLabel: t("common.table.headers.status"),
content: ( content: (
<Typography <Stack
component="div"
display="inline-flex"
alignItems="center"
gap={theme.spacing(4)} gap={theme.spacing(4)}
direction={"row"}
justifyContent={"center"}
alignItems={"center"}
onClick={(e) => handleSort(e, "status")} onClick={(e) => handleSort(e, "status")}
sx={{ cursor: "pointer" }} sx={{ cursor: "pointer" }}
> >
<Box width={theme.spacing(8)} />
{t("common.table.headers.status")} {t("common.table.headers.status")}
{renderSortIcon(sortField === "status")} {renderSortIcon(sortField === "status")}
</Typography> </Stack>
), ),
render: (row) => { render: (row) => {
return <StatusLabel status={row.status} />; return <StatusLabel status={row.status} />;
@@ -192,6 +192,7 @@ export const MonitorTable = ({
}, },
{ {
id: "name", id: "name",
align: "left",
mobileLabel: t("common.table.headers.name"), mobileLabel: t("common.table.headers.name"),
content: ( content: (
<Stack <Stack
@@ -217,6 +218,7 @@ export const MonitorTable = ({
<Stack <Stack
gap={theme.spacing(4)} gap={theme.spacing(4)}
direction={"row"} direction={"row"}
justifyContent={"center"}
alignItems={"center"} alignItems={"center"}
onClick={(e) => handleSort(e, "status")} onClick={(e) => handleSort(e, "status")}
sx={{ cursor: "pointer" }} sx={{ cursor: "pointer" }}