From f4da9bd09e66090f26c0c949b029616cf484bb70 Mon Sep 17 00:00:00 2001 From: Kyle Cunningham Date: Tue, 5 Mar 2024 13:00:41 -0600 Subject: [PATCH] Table Panel: Text wrapping fix inspect viewing issues (#83867) * Fix inspect viewing issues * Fix long line wrapping * Prettier * Fix text wrapping * Fix overflowing text --- .../src/components/Table/DefaultCell.tsx | 26 +++++-------------- .../grafana-ui/src/components/Table/styles.ts | 8 +++--- 2 files changed, 11 insertions(+), 23 deletions(-) diff --git a/packages/grafana-ui/src/components/Table/DefaultCell.tsx b/packages/grafana-ui/src/components/Table/DefaultCell.tsx index 90628ee0d65..a8f6436d742 100644 --- a/packages/grafana-ui/src/components/Table/DefaultCell.tsx +++ b/packages/grafana-ui/src/components/Table/DefaultCell.tsx @@ -132,25 +132,13 @@ function getCellStyle( // If we have definied colors return those styles // Otherwise we return default styles - if (textColor !== undefined || bgColor !== undefined) { - return tableStyles.buildCellContainerStyle( - textColor, - bgColor, - !disableOverflowOnHover, - isStringValue, - shouldWrapText - ); - } - - if (isStringValue) { - return disableOverflowOnHover - ? tableStyles.buildCellContainerStyle(undefined, undefined, false, true, shouldWrapText) - : tableStyles.buildCellContainerStyle(undefined, undefined, true, true, shouldWrapText); - } else { - return disableOverflowOnHover - ? tableStyles.buildCellContainerStyle(undefined, undefined, false, shouldWrapText) - : tableStyles.buildCellContainerStyle(undefined, undefined, true, false, shouldWrapText); - } + return tableStyles.buildCellContainerStyle( + textColor, + bgColor, + !disableOverflowOnHover, + isStringValue, + shouldWrapText + ); } function getLinkStyle(tableStyles: TableStyles, cellOptions: TableCellOptions, targetClassName: string | undefined) { diff --git a/packages/grafana-ui/src/components/Table/styles.ts b/packages/grafana-ui/src/components/Table/styles.ts index 2446d96d9c3..787e2ee5b51 100644 --- a/packages/grafana-ui/src/components/Table/styles.ts +++ b/packages/grafana-ui/src/components/Table/styles.ts @@ -49,14 +49,14 @@ export function useTableStyles(theme: GrafanaTheme2, cellHeightOption: TableCell '&:hover': { overflow: overflowOnHover ? 'visible' : undefined, - width: textShouldWrap ? 'auto' : 'auto !important', - height: textShouldWrap ? 'auto !important' : `${rowHeight - 1}px`, + width: textShouldWrap || !overflowOnHover ? 'auto' : 'auto !important', + height: textShouldWrap || overflowOnHover ? 'auto !important' : `${rowHeight - 1}px`, minHeight: `${rowHeight - 1}px`, wordBreak: textShouldWrap ? 'break-word' : undefined, - whiteSpace: overflowOnHover ? 'normal' : 'nowrap', + whiteSpace: textShouldWrap && overflowOnHover ? 'normal' : 'nowrap', boxShadow: overflowOnHover ? `0 0 2px ${theme.colors.primary.main}` : undefined, background: overflowOnHover ? background ?? theme.components.table.rowHoverBackground : undefined, - zIndex: overflowOnHover ? 1 : undefined, + zIndex: 1, '.cellActions': { visibility: 'visible', opacity: 1,