Repository navigation
fix:content search pagination - #681
Conversation
gkhngyk
left a comment
There was a problem hiding this comment.
This is the preferred fix from #664 — server-side q over title/description, the 300ms debounce, and keying the pager on debouncedSearch so the page resets and total reflects the search. Nice.
One real defect in the escaping: PostgREST's .or() logic parser doesn't support backslash escapes, so
const search = String(q).replace(/([,()])/g, '\\$1');doesn't protect anything — a search containing a comma (e.g. keyword research, planning) still splits the or= expression, PostgREST returns 400, and the user sees "Failed to load". The two working options:
- Simplest: strip the reserved chars instead of escaping —
String(q).replace(/[,()]/g, ' ')(they're never meaningful in a fuzzy search anyway), or - Proper PostgREST quoting: wrap the pattern in double quotes —
title.ilike."%${escaped}%"with embedded"/\\escaped.
Also a heads-up: #682 (same author 🙂) touches the same loadData/effect — whichever merges first, the other needs a quick rebase; the isCancelled guard there should wrap this PR's search fetches too.
Happy to approve with the escaping sorted.
83acc70 to
46fd029
Compare
Summary
qparameter.Related issue
Closes #664
Type of change
feat— New featurefix— Bug fixchore— Maintenance / dependenciesdocs— Documentation onlyrefactor— Code change that neither fixes a bug nor adds a featuretest— Adding or updating testsChecklist
feature/,fix/,chore/,docs/) — see https://github.com/ansvisor/ansvisor/blob/main/CONTRIBUTING.mdyarn lintpasses (run fromweb/)yarn typecheckpasses (run fromweb/)yarn format:checkpasses (run fromweb/)