Skip to content

Commit fcfdd75

Browse files
committed
Fix errors on client-side search and show no rows available if no rows found in a configured table
1 parent 325c2e9 commit fcfdd75

File tree

1 file changed

+22
-6
lines changed

1 file changed

+22
-6
lines changed

src/lib/components/Table/TableContent.svelte

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -389,9 +389,12 @@
389389
<form
390390
class="flex gap-2"
391391
on:submit|preventDefault={() => {
392-
if (!sendModel) throw new Error('Server-side configuration is missing');
392+
if (serverSide && !sendModel) {
393+
throw new Error('Server-side configuration is missing');
394+
} else {
395+
sendModel.q = searchValue;
396+
}
393397

394-
sendModel.q = searchValue;
395398
$filterValue = searchValue;
396399
}}
397400
>
@@ -407,10 +410,13 @@
407410
id="{tableId}-searchReset"
408411
class="absolute right-3 items-center"
409412
on:click|preventDefault={() => {
410-
if (!sendModel) throw new Error('Server-side configuration is missing');
413+
if (serverSide && !sendModel) {
414+
throw new Error('Server-side configuration is missing');
415+
} else {
416+
sendModel.q = '';
417+
}
411418

412419
searchValue = '';
413-
sendModel.q = '';
414420
$filterValue = '';
415421
}}><Fa icon={faXmark} /></button
416422
>
@@ -420,10 +426,13 @@
420426
id="{tableId}-searchSubmit"
421427
class="btn variant-filled-primary"
422428
on:click|preventDefault={() => {
423-
if (!sendModel) throw new Error('Server-side configuration is missing');
429+
if (serverSide && !sendModel) {
430+
throw new Error('Server-side configuration is missing');
431+
} else {
432+
sendModel.q = searchValue;
433+
}
424434

425435
$filterValue = searchValue;
426-
sendModel.q = searchValue;
427436
}}>Search</button
428437
>
429438
</form>
@@ -564,6 +573,13 @@
564573
{/each}
565574
</tbody>
566575
</table>
576+
{#if $pageRows.length === 0}
577+
<div
578+
class="p-8 flex items-center justify-center bg-tertiary-500/30 dark:bg-tertiary-900/10"
579+
>
580+
No rows available
581+
</div>
582+
{/if}
567583
</div>
568584
</div>
569585
{:else}

0 commit comments

Comments
 (0)