Skip to content

fix:content search pagination - #681

Merged
gkhngyk merged 3 commits into
ansvisor:mainfrom
BharadwajKanneveti:fix/content-search-pagination
Aug 9, 2026
Merged

gkhngyk merged 3 commits into
ansvisor:mainfrom
BharadwajKanneveti:fix/content-search-pagination

Conversation

@BharadwajKanneveti

Copy link
Copy Markdown
Contributor

Summary

  • Added server-side search for content opportunities using the q parameter.
  • Search now matches opportunity titles and descriptions across all paginated results.
  • Debounced the search input to avoid sending a request on every keystroke.
  • Reset pagination when search or other filters change.
  • Updated the pager to use the total returned for the current search/filter results, preventing contradictory pagination counts.

Related issue

Closes #664

Type of change

  • feat — New feature
  • fix — Bug fix
  • chore — Maintenance / dependencies
  • docs — Documentation only
  • refactor — Code change that neither fixes a bug nor adds a feature
  • test — Adding or updating tests

Checklist

@BharadwajKanneveti BharadwajKanneveti changed the title Fix/content search pagination fix:content search pagination Aug 7, 2026

@gkhngyk gkhngyk left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:

  1. Simplest: strip the reserved chars instead of escaping — String(q).replace(/[,()]/g, ' ') (they're never meaningful in a fuzzy search anyway), or
  2. 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.

@BharadwajKanneveti
BharadwajKanneveti force-pushed the fix/content-search-pagination branch from 83acc70 to 46fd029 Compare August 8, 2026 15:49

@gkhngyk gkhngyk left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Escaping sorted — stripping the reserved characters is the right call for a fuzzy search, and the rebase onto #682 kept the isCancelled guard covering the search fetches too. Debounce, pager reset via the debouncedSearch key, and the server-side q all line up. Closes #664 properly. Thanks!

@gkhngyk
gkhngyk merged commit 479b9bf into ansvisor:main Aug 9, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Content: search only filters the loaded page and contradicts the pager

2 participants