From 1f967a89b64f8f6319db6930ff8e0fc438b56bff Mon Sep 17 00:00:00 2001 From: Galen Kistler <109082771+gtk-grafana@users.noreply.github.com> Date: Tue, 11 Jun 2024 06:40:29 -0500 Subject: [PATCH] Frontend: InteractiveTable fix - prevent styles from leaking into tables added in expanded rows (#88948) * fix: prevent styles from leaking into tables added in expanded rows --- .../InteractiveTable/InteractiveTable.tsx | 50 +++++++++---------- 1 file changed, 24 insertions(+), 26 deletions(-) diff --git a/packages/grafana-ui/src/components/InteractiveTable/InteractiveTable.tsx b/packages/grafana-ui/src/components/InteractiveTable/InteractiveTable.tsx index a1ced1b5d0c..e750b29bb1c 100644 --- a/packages/grafana-ui/src/components/InteractiveTable/InteractiveTable.tsx +++ b/packages/grafana-ui/src/components/InteractiveTable/InteractiveTable.tsx @@ -34,23 +34,20 @@ const getStyles = (theme: GrafanaTheme2) => { width: '100%', overflowX: 'auto', }), + cell: css({ + padding: theme.spacing(1), + minWidth: theme.spacing(3), + }), table: css({ borderRadius: theme.shape.radius.default, width: '100%', - - td: { - padding: theme.spacing(1), - }, - - 'td, th': { - minWidth: theme.spacing(3), - }, }), disableGrow: css({ width: 0, }), header: css({ borderBottom: `1px solid ${theme.colors.border.weak}`, + minWidth: theme.spacing(3), '&, & > button': { position: 'relative', whiteSpace: 'nowrap', @@ -85,24 +82,23 @@ const getStyles = (theme: GrafanaTheme2) => { label: 'expanded-row-content', borderBottom: 'none', }), + expandedContentCell: css({ + borderBottom: `1px solid ${theme.colors.border.weak}`, + position: 'relative', + padding: theme.spacing(2, 2, 2, 5), + + '&:before': { + content: '""', + position: 'absolute', + width: '1px', + top: 0, + left: '16px', + bottom: theme.spacing(2), + background: theme.colors.border.medium, + }, + }), expandedContentRow: css({ label: 'expanded-row-content', - - td: { - borderBottom: `1px solid ${theme.colors.border.weak}`, - position: 'relative', - padding: theme.spacing(2, 2, 2, 5), - - '&:before': { - content: '""', - position: 'absolute', - width: '1px', - top: 0, - left: '16px', - bottom: theme.spacing(2), - background: theme.colors.border.medium, - }, - }, }), sortableHeader: css({ /* increases selector's specificity so that it always takes precedence over default styles */ @@ -290,7 +286,7 @@ export function InteractiveTable({ {row.cells.map((cell) => { const { key, ...otherCellProps } = cell.getCellProps(); return ( - + {cell.render('Cell', { __rowID: rowId })} ); @@ -298,7 +294,9 @@ export function InteractiveTable({ {isExpanded && renderExpandedRow && ( - {renderExpandedRow(row.original)} + + {renderExpandedRow(row.original)} + )}