Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/web/src/components/data-table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ export function DataTable<TData extends RowData>({
))}
</TableHeader>
<TableBody>
{enableVirtualization && virtualRows ? (
{enableVirtualization && virtualRows && rows.length ? (
<>
{/* Top spacer */}
{virtualRows.length > 0 && virtualRows[0].start > 0 && (
Expand Down
5 changes: 3 additions & 2 deletions tests/fixtures/lead_selection_server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,16 @@ const selection=rows=>window.selected=rows.map(row=>row.id);
const columns=[{accessorKey:'email',header:'Email'}];
function Probe(){const [rows,setRows]=useState(initial);window.refresh=()=>flushSync(()=>setRows([...initial]));window.replace=()=>flushSync(()=>setRows([second,third]));return <DataTable columns={columns} data={rows} enableSelection enableVirtualization={false} onSelectionChange={selection}/>;}
const root=createRoot(document.getElementById('root'));root.render(<Probe/>);
window.unmount=()=>root.unmount();
const emptyRoot=createRoot(document.getElementById('virtual-empty'));emptyRoot.render(<DataTable columns={columns} data={[]}/>);
window.unmount=()=>{root.unmount();emptyRoot.unmount();};
`);
let result;
try {result=await Bun.build({entrypoints:[entry],target:'browser'});} finally {await Bun.file(entry).delete();}
if(!result.success)throw new Error(String(result.logs));
const bundle=await result.outputs[0].text();
const server=Bun.serve({hostname:'127.0.0.1',port:0,fetch(req){
if(new URL(req.url).pathname==='/bundle.js')return new Response(bundle,{headers:{'Content-Type':'application/javascript'}});
return new Response('<style>[role=checkbox]{display:inline-block;width:20px;height:20px;border:1px solid black}</style><div id="root"></div><script type="module" src="/bundle.js"></script>',{headers:{'Content-Type':'text/html'}});
return new Response('<style>[role=checkbox]{display:inline-block;width:20px;height:20px;border:1px solid black}</style><div id="root"></div><div id="virtual-empty"></div><script type="module" src="/bundle.js"></script>',{headers:{'Content-Type':'text/html'}});
}});
console.log(JSON.stringify({port:server.port}));
process.on('SIGTERM',()=>{server.stop(true);process.exit(0);});
2 changes: 2 additions & 0 deletions tests/test_lead_selection_browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ def test_lead_table_clears_selection_when_backing_records_change():
snapshot={'selected_ids':page.evaluate('selected'),'first_visible_lead':'second@example.test','checked':page.get_by_role('checkbox',name='Select row').first.is_checked(),'unchanged_rows_preserve_selection':unchanged,'errors':errors}
print(json.dumps(snapshot,indent=2))
assert snapshot['selected_ids']==[] and not snapshot['checked'] and unchanged and not errors
# Virtualized (default) table with no rows still renders its empty state.
page.locator('#virtual-empty').get_by_text('No results.',exact=True).wait_for(timeout=5000)
page.evaluate('unmount()')
finally:browser.close()
finally:
Expand Down
Loading