Skip to content

Commit efd2b3d

Browse files
committed
show a warning message instead of an error when the cell has not loaded yet
1 parent 47e5c46 commit efd2b3d

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

src/components/Cell/Cell.tsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ interface CellProps {
1515
col: number
1616
}
1717

18+
const UNLOADED_CELL_PLACEHOLDER = '<the content has not been fetched yet>'
19+
1820
/**
1921
* Cell viewer displays a single cell from a table.
2022
*/
@@ -46,10 +48,7 @@ export default function CellView({ source, row, col }: CellProps) {
4648
}
4749
await df.fetch({ rowStart: row, rowEnd: row + 1, columns: [columnName] })
4850
const cell = df.getCell({ row, column: columnName })
49-
if (cell === undefined) {
50-
throw new Error(`Cell at row=${row}, col=${col} is undefined`)
51-
}
52-
const text = stringify(cell.value)
51+
const text = cell === undefined ? UNLOADED_CELL_PLACEHOLDER : stringify(cell.value)
5352
setText(text)
5453
setError(undefined)
5554
} catch (error) {

src/components/CellPanel/CellPanel.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ interface ViewerProps {
1717
onClose: () => void
1818
}
1919

20+
const UNLOADED_CELL_PLACEHOLDER = '<the content has not been fetched yet>'
21+
2022
/**
2123
* Cell viewer displays a single cell from a table.
2224
*/
@@ -37,7 +39,13 @@ export default function CellPanel({ df, row, col, setProgress, setError, onClose
3739
await df.fetch({ rowStart: row, rowEnd: row + 1, columns: [columnName] })
3840
const cell = df.getCell({ row, column: columnName })
3941
if (cell === undefined) {
40-
throw new Error(`Cell at row=${row}, col=${col} is undefined`)
42+
setContent(
43+
<code className={cn(jsonStyles.textView, customClass?.textView)}>
44+
{/* TODO(SL) maybe change the style to highlight it's not real content */}
45+
{UNLOADED_CELL_PLACEHOLDER}
46+
</code>
47+
)
48+
return
4149
}
4250
const value: unknown = await cell.value
4351
if (value instanceof Object && !(value instanceof Date)) {

0 commit comments

Comments
 (0)