refactor: pagination and table components #33
Loading…
Reference in a new issue
No description provided.
Delete branch "refactor/pagination-and-table"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
PR Review: refactor pagination and table components
Overall, this is a solid refactoring that introduces reusable table and pagination components. The code is clean, passes linting, type checking, and formatting checks. Here are my findings:
🔴 Critical Issue
1. Invalid HTML tag in
TableBodyCell.sveltesrc/components/table/TableBodyCell.svelteuses<tb>as the wrapper element, which is not valid HTML. This should be<td>(table data cell).This is a clear typo that will break table rendering in all browsers.
⚠️ Important Issues
2. Pagination loses sort state on page change
In
Pagination.svelte, theonPageChangehandler only updates the page number:This means when a user sorts a column and then clicks to page 2, the sort is lost. The handler should preserve
sortColumnandsortDirection:3. Sort column names don't match database columns
TableHeadCellreferences sort columns like"name"and"username", but the database schema usescreatedAt(notnameorusernameas direct sort columns in the DB). ThePaginationSortColumntype correctly lists["createdAt", "name", "username"], so this is fine at the type level — but the display label"Creato"in the users page maps tocreatedAtwhich is correct. No actual bug here, just noting that the column naming convention is consistent.💡 Suggestions
4. Table component lacks class prop
The
Tablecomponent doesn't accept aclassprop, so there's no way to apply Tailwind styling. Consider adding one:5.
TableHeadCellgeneric type parameter is unusedThe
generics="C extends string"is declared but doesn't add meaningful type safety — thecolumnNameprop is typed asCbut there's no constraint enforcement at the call site. Consider simplifying or removing the generic.6.
TableHeadCellURL generation drops sort directionWhen clicking a column header to sort by a different column, the URL is generated without the current
sortDirection. This means clicking "Name" when already sorted by "Username (asc)" will default todesc(the initial state). This might be intentional behavior, but worth confirming.📝 Minor / Cosmetic
7. AGENTS.md has a duplicate "Package.json scripts" section
The section appears to have been added while the old "Testing" and "CI/CD" sections were still present. The diff shows the new section was prepended but the old content wasn't fully removed (the resulting file looks correct, but the diff could be cleaner).
8. README.md has trailing whitespace
The project structure diagram has trailing whitespace on some lines (e.g.,
└── auth/ # Authentication pages).✅ Positive Notes
paginationSchemaFactorypattern is a nice abstraction for reusable pagination_forms.remote.tsand_schemas.ts) is cleanerTableHeadCellwith inline sorting support is a great reusable componentSummary
<tb>should be<td>in TableBodyCellI'd recommend fixing the
<tb>→<td>typo and the pagination sort state issue before merging.@ -0,0 +21,4 @@count={itemsCount}page={paginationOptions.page}perPage={pageSize}class="flex items-center gap-1 font-semibold text-slate-600"This should preserve sortColumn and sortDirection to avoid losing sort state on page change
@ -0,0 +8,4 @@const { children }: Props = $props();</script><tb>Invalid HTML tag - should be , not