Skip to content

Commit 55cf1f6

Browse files
committed
fix: The column width at Error
1 parent 08b1053 commit 55cf1f6

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

src/pages/notebook/notebook-middle/notebook-middle-data-result.tsx

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,14 @@ function DataResult({ data, isLoading }: DataResultProps) {
4747
};
4848

4949
// Data columns
50+
const isSingleColumn = data.header.length === 1;
51+
5052
const dataColumns: ColumnDef<string[]>[] = data.header.map(
5153
(header, index) => ({
5254
id: `col_${index}`,
5355
accessorFn: (row: string[]) => row[index],
5456
header: header,
55-
size: DEFAULT_COLUMN_WIDTH,
57+
size: isSingleColumn ? 9999 : DEFAULT_COLUMN_WIDTH,
5658
minSize: 50,
5759
})
5860
);
@@ -165,6 +167,7 @@ function DataResult({ data, isLoading }: DataResultProps) {
165167
const totalSize = virtualizer.getTotalSize();
166168
const { rows: tableRows } = table.getRowModel();
167169
const tableWidth = table.getTotalSize();
170+
const isSingleColumn = data.header.length === 1;
168171

169172
return (
170173
<div className="w-full">
@@ -192,7 +195,11 @@ function DataResult({ data, isLoading }: DataResultProps) {
192195
? "text-center sticky left-0 bg-default-100 z-30"
193196
: "text-left"
194197
}`}
195-
style={{ width: header.getSize() }}
198+
style={
199+
isSingleColumn && header.id !== "_index"
200+
? { flex: 1 }
201+
: { width: header.getSize() }
202+
}
196203
>
197204
{flexRender(
198205
header.column.columnDef.header,
@@ -249,7 +256,11 @@ function DataResult({ data, isLoading }: DataResultProps) {
249256
}`
250257
: "text-left"
251258
}`}
252-
style={{ width: cell.column.getSize() }}
259+
style={
260+
isSingleColumn && cell.column.id !== "_index"
261+
? { flex: 1 }
262+
: { width: cell.column.getSize() }
263+
}
253264
>
254265
{flexRender(
255266
cell.column.columnDef.cell,

0 commit comments

Comments
 (0)