diff --git a/.betterer.results b/.betterer.results index 2f9307b0639..7dfcd646d68 100644 --- a/.betterer.results +++ b/.betterer.results @@ -835,8 +835,7 @@ exports[`better eslint`] = { [0, 0, 0, "Unexpected any. Specify a different type.", "3"] ], "packages/grafana-ui/src/components/Table/TableCellInspector.tsx:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"], - [0, 0, 0, "No untranslated strings. Wrap text with ", "1"] + [0, 0, 0, "Unexpected any. Specify a different type.", "0"] ], "packages/grafana-ui/src/components/Table/reducer.ts:5381": [ [0, 0, 0, "Do not use any type assertions.", "0"], diff --git a/packages/grafana-ui/src/components/Table/RowsList.tsx b/packages/grafana-ui/src/components/Table/RowsList.tsx index 7e00eded5bb..4d3d7a1afb4 100644 --- a/packages/grafana-ui/src/components/Table/RowsList.tsx +++ b/packages/grafana-ui/src/components/Table/RowsList.tsx @@ -398,12 +398,15 @@ export const RowsList = (props: RowsListProps) => { } }; + // Key the virtualizer for expanded rows + const expandedKey = Object.keys(tableState.expanded).join('|'); + return ( <> void; mode: TableCellInspectorMode; @@ -28,11 +30,17 @@ export function TableCellInspector({ value, onDismiss, mode }: TableCellInspecto if (trimmedValue[0] === '{' || trimmedValue[0] === '[' || mode === 'code') { try { value = JSON.parse(value); - displayValue = JSON.stringify(value, null, ''); - } catch {} + displayValue = JSON.stringify(value, null, ' '); + } catch (error: any) { + // Display helpful error to help folks diagnose json errors + console.log( + 'Failed to parse JSON in Table cell inspector (this will cause JSON to not print nicely): ', + error.message + ); + } } } else { - displayValue = JSON.stringify(value, null, ''); + displayValue = JSON.stringify(value); } let text = displayValue; @@ -63,7 +71,7 @@ export function TableCellInspector({ value, onDismiss, mode }: TableCellInspecto text} style={{ marginLeft: 'auto', width: '200px' }}> - Copy to Clipboard + Copy to Clipboard {currentMode === 'code' ? (