Skip to content

SigNoz is an open-source, OpenTelemetry-native observability platform for your team and their AI agents. Get logs, metrics, and traces in one tool with features like APM, distributed tracing, log management, infra monitoring, etc. Combined with SigNoz MCP and a native AI teammate (in SigNoz Cloud) it helps you build more resilient apps.

fix: fix the layout shift issues in logs explorer column view (#8434)

Shaheer Kochai15332b90c1a1
diff --git a/frontend/src/components/Logs/TableView/config.ts b/frontend/src/components/Logs/TableView/config.ts
index e5571828e1..6723a8c959 100644
--- a/frontend/src/components/Logs/TableView/config.ts
+++ b/frontend/src/components/Logs/TableView/config.ts
@@ -15,6 +15,7 @@ export function getDefaultCellStyle(isDarkMode?: boolean): CSSProperties {
letterSpacing: '-0.07px',
marginBottom: '0px',
minWidth: '10rem',
+ width: '10rem',
};
}
diff --git a/frontend/src/components/Logs/TableView/useTableView.tsx b/frontend/src/components/Logs/TableView/useTableView.tsx
index 9971f6d775..8b97f6cfd2 100644
--- a/frontend/src/components/Logs/TableView/useTableView.tsx
+++ b/frontend/src/components/Logs/TableView/useTableView.tsx
@@ -47,6 +47,14 @@ export const useTableView = (props: UseTableViewProps): UseTableViewResult => {
const { formatTimezoneAdjustedTimestamp } = useTimezone();
+ const bodyColumnStyle = useMemo(
+ () => ({
+ ...defaultTableStyle,
+ ...(fields.length > 2 ? { width: '50rem' } : {}),
+ }),
+ [fields.length],
+ );
+
const columns: ColumnsType<Record<string, unknown>> = useMemo(() => {
const fieldColumns: ColumnsType<Record<string, unknown>> = fields
.filter((e) => !['id', 'body', 'timestamp'].includes(e.name))
@@ -136,7 +144,7 @@ export const useTableView = (props: UseTableViewProps): UseTableViewResult => {
field: string | number,
): ColumnTypeRender<Record<string, unknown>> => ({
props: {
- style: defaultTableStyle,
+ style: bodyColumnStyle,
},
children: (
<TableBodyContent
@@ -166,6 +174,7 @@ export const useTableView = (props: UseTableViewProps): UseTableViewResult => {
linesPerRow,
fontSize,
formatTimezoneAdjustedTimestamp,
+ bodyColumnStyle,
]);
return { columns, dataSource: flattenLogData };
diff --git a/frontend/src/container/LogsExplorerList/InfinityTableView/TableRow.tsx b/frontend/src/container/LogsExplorerList/InfinityTableView/TableRow.tsx
index 6712c609c2..1c591c1ef0 100644
--- a/frontend/src/container/LogsExplorerList/InfinityTableView/TableRow.tsx
+++ b/frontend/src/container/LogsExplorerList/InfinityTableView/TableRow.tsx
@@ -57,6 +57,10 @@ export default function TableRow({
[currentLog, handleSetActiveContextLog],
);
+ const hasSingleColumn =
+ tableColumns.filter((column) => column.key !== 'state-indicator').length ===
+ 1;
+
return (
<>
{tableColumns.map((column) => {
@@ -80,9 +84,11 @@ export default function TableRow({
<TableCellStyled
$isDragColumn={false}
$isLogIndicator={column.key === 'state-indicator'}
+ $hasSingleColumn={hasSingleColumn}
$isDarkMode={isDarkMode}
key={column.key}
fontSize={fontSize}
+ columnKey={column.key as string}
>
{cloneElement(children, props)}
</TableCellStyled>
diff --git a/frontend/src/container/LogsExplorerList/InfinityTableView/index.tsx b/frontend/src/container/LogsExplorerList/InfinityTableView/index.tsx
index 9aa982abe7..339bdf135b 100644
--- a/frontend/src/container/LogsExplorerList/InfinityTableView/index.tsx
+++ b/frontend/src/container/LogsExplorerList/InfinityTableView/index.tsx
@@ -135,6 +135,7 @@ const InfinityTable = forwardRef<TableVirtuosoHandle, InfinityTableProps>(
fontSize={tableViewProps?.fontSize}
// eslint-disable-next-line react/jsx-props-no-spreading
{...(isDragColumn && { className: 'dragHandler' })}
+ columnKey={column.key as string}
>
{(column.title as string).replace(/^\w/, (c) => c.toUpperCase())}
</TableHeaderCellStyled>
diff --git a/frontend/src/container/LogsExplorerList/InfinityTableView/styles.ts b/frontend/src/container/LogsExplorerList/InfinityTableView/styles.ts
index a22e7a4cc0..5d5d747733 100644
--- a/frontend/src/container/LogsExplorerList/InfinityTableView/styles.ts
+++ b/frontend/src/container/LogsExplorerList/InfinityTableView/styles.ts
@@ -8,13 +8,25 @@ interface TableHeaderCellStyledProps {
$isDragColumn: boolean;
$isDarkMode: boolean;
$isLogIndicator?: boolean;
+ $hasSingleColumn?: boolean;
fontSize?: FontSize;
+ columnKey?: string;
}
export const TableStyled = styled.table`
width: 100%;
`;
+const getTimestampColumnWidth = (
+ columnKey?: string,
+ $hasSingleColumn?: boolean,
+): string =>
+ columnKey === 'timestamp'
+ ? $hasSingleColumn
+ ? 'width: 100%;'
+ : 'width: 10%;'
+ : '';
+
export const TableCellStyled = styled.td<TableHeaderCellStyledProps>`
padding: 0.5rem;
${({ fontSize }): string =>
@@ -29,9 +41,12 @@ export const TableCellStyled = styled.td<TableHeaderCellStyledProps>`
props.$isDarkMode ? 'inherit' : themeColors.whiteCream};
${({ $isLogIndicator }): string =>
- $isLogIndicator ? 'padding: 0 0 0 8px;width: 15px;' : ''}
+ $isLogIndicator ? 'padding: 0 0 0 8px;width: 1%;' : ''}
color: ${(props): string =>
props.$isDarkMode ? themeColors.white : themeColors.bckgGrey};
+
+ ${({ columnKey, $hasSingleColumn }): string =>
+ getTimestampColumnWidth(columnKey, $hasSingleColumn)}
`;
export const TableRowStyled = styled.tr<{
@@ -86,7 +101,11 @@ export const TableHeaderCellStyled = styled.th<TableHeaderCellStyledProps>`
: fontSize === FontSize.LARGE
? `font-size:14px; line-height:24px; padding: 0.5rem;`
: ``};
- ${({ $isLogIndicator }): string => ($isLogIndicator ? 'padding: 0px; ' : '')}
+ ${({ $isLogIndicator }): string =>
+ $isLogIndicator ? 'padding: 0px; width: 1%;' : ''}
color: ${(props): string =>
props.$isDarkMode ? 'var(--bg-vanilla-100, #fff)' : themeColors.bckgGrey};
+
+ ${({ columnKey, $hasSingleColumn }): string =>
+ getTimestampColumnWidth(columnKey, $hasSingleColumn)}
`;