Skip to content

Commit b0e526d

Browse files
committed
fix: data table wrapping
1 parent b8bbc27 commit b0e526d

File tree

3 files changed

+408
-19
lines changed

3 files changed

+408
-19
lines changed

packages/core/components/DataTable/helpers/mapCellMatrix.tsx

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import CellAnchor from '../components/CellAnchor'
33
import { DataTableProps } from '../DataTable'
44
import { ReactNode } from 'react'
55
import { displayDataAsText } from '@cdc/core/helpers/displayDataAsText'
6+
import parse from 'html-react-parser'
67
import _ from 'lodash'
78
import { hashObj } from '../../../helpers/hashObj'
89
import { sanitizeToSvgId } from '../../../helpers/cove/string'
@@ -136,24 +137,26 @@ const mapCellArray = ({
136137
const sanitizedPatternDataKey = sanitizeToSvgId(patternInfo?.dataKey || '')
137138

138139
return (
139-
<div className='col-12'>
140-
{validColor ? (
141-
patternInfo ? (
142-
<LegendShape
143-
fill={legendColor[0]}
144-
patternInfo={{
145-
pattern: patternInfo.pattern,
146-
patternId: `${mapId}--${sanitizedPatternDataKey}--${patternInfo.patternIndex}--table`,
147-
size: patternInfo.size,
148-
color: patternInfo.color
149-
}}
150-
/>
140+
<div style={{ display: 'flex', alignItems: 'flex-start', flexWrap: 'nowrap', whiteSpace: 'nowrap' }}>
141+
<div style={{ flexShrink: 0 }}>
142+
{validColor ? (
143+
patternInfo ? (
144+
<LegendShape
145+
fill={legendColor[0]}
146+
patternInfo={{
147+
pattern: patternInfo.pattern,
148+
patternId: `${mapId}--${sanitizedPatternDataKey}--${patternInfo.patternIndex}--table`,
149+
size: patternInfo.size,
150+
color: patternInfo.color
151+
}}
152+
/>
153+
) : (
154+
<LegendShape fill={legendColor[0]} />
155+
)
151156
) : (
152-
<LegendShape fill={legendColor[0]} />
153-
)
154-
) : (
155-
<div className='d-inline-block me-2' style={{ width: '1rem', height: '1rem' }} />
156-
)}
157+
<div className='me-2' style={{ width: '1rem', height: '1rem' }} />
158+
)}
159+
</div>
157160
<CellAnchor
158161
markup={labelValue}
159162
row={rowObj}
@@ -166,7 +169,8 @@ const mapCellArray = ({
166169
} else {
167170
const rowData = runtimeData[row]
168171
const dataValue = getDataValue(config, rowData, column)
169-
return displayDataAsText(dataValue, column, config)
172+
const text = displayDataAsText(dataValue, column, config)
173+
return typeof text === 'string' ? parse(text) : text
170174
}
171175
})
172176
)

0 commit comments

Comments
 (0)