From 94d4d9c6ea34a0e4ca19519a039006ece2fdda97 Mon Sep 17 00:00:00 2001 From: debpalash <4178343+debpalash@users.noreply.github.com> Date: Tue, 13 Oct 2026 09:47:28 +0530 Subject: [PATCH] fix(web): show "No results." in virtualized empty tables The virtualized branch was chosen whenever virtualization was on, because an empty virtual-item array is truthy, so the empty-state row never rendered. On the Leads page a company filter matching nothing showed a blank table. Signed-off-by: debpalash Co-Authored-By: Claude Opus 5.5 --- apps/web/src/components/data-table.tsx | 2 +- tests/fixtures/lead_selection_server.ts | 5 +++-- tests/test_lead_selection_browser.py | 2 ++ 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/apps/web/src/components/data-table.tsx b/apps/web/src/components/data-table.tsx index 1a5ad255..12643f8e 100644 --- a/apps/web/src/components/data-table.tsx +++ b/apps/web/src/components/data-table.tsx @@ -267,7 +267,7 @@ export function DataTable({ ))} - {enableVirtualization && virtualRows ? ( + {enableVirtualization && virtualRows && rows.length ? ( <> {/* Top spacer */} {virtualRows.length > 0 && virtualRows[0].start > 0 && ( diff --git a/tests/fixtures/lead_selection_server.ts b/tests/fixtures/lead_selection_server.ts index e583abe7..a3461e1e 100644 --- a/tests/fixtures/lead_selection_server.ts +++ b/tests/fixtures/lead_selection_server.ts @@ -12,7 +12,8 @@ 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 ;} const root=createRoot(document.getElementById('root'));root.render(); -window.unmount=()=>root.unmount(); +const emptyRoot=createRoot(document.getElementById('virtual-empty'));emptyRoot.render(); +window.unmount=()=>{root.unmount();emptyRoot.unmount();}; `); let result; try {result=await Bun.build({entrypoints:[entry],target:'browser'});} finally {await Bun.file(entry).delete();} @@ -20,7 +21,7 @@ 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('
',{headers:{'Content-Type':'text/html'}}); + return new Response('
',{headers:{'Content-Type':'text/html'}}); }}); console.log(JSON.stringify({port:server.port})); process.on('SIGTERM',()=>{server.stop(true);process.exit(0);}); diff --git a/tests/test_lead_selection_browser.py b/tests/test_lead_selection_browser.py index 1dfa21d7..a99fbb0e 100644 --- a/tests/test_lead_selection_browser.py +++ b/tests/test_lead_selection_browser.py @@ -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: