Skip to content

🐞[Bug]: handleSearch in HomeScreen searches only the last-fetched page instead of all accumulated articles (allArticlesRef.current) #1358

@jyoti-5906

Description

@jyoti-5906

Related Area

Frontend

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

In HomeScreen.tsx, the app uses a paginated article loader that accumulates all fetched articles into allArticlesRef.current across multiple pages. However, the handleSearch function searches only articleData?.articles β€” which is the React Query result containing only the most recently fetched page β€” instead of allArticlesRef.current which holds all accumulated articles.

Every other consumer in the component uses allArticlesRef.current correctly:

  • updateArticles(allArticlesRef.current) β€” category filter
  • handleFilterReset β€” dispatch uses allArticlesRef.current
  • Auto-pagination guard β€” filters from allArticlesRef.current

Only handleSearch was left pointing at the stale per-page snapshot.

Affected file: frontend/src/screens/HomeScreen.tsx

Buggy code (line ~479):
const matchesSearch = articleData?.articles.filter(article => { ... });

Expected behavior

Searching should match against all articles loaded so far across all pages (allArticlesRef.current), not just the articles returned by the most recent page fetch. If a user has scrolled through 3 pages and searches for an article from page 1, it should appear in results.

Add ScreenShots

Image Image

What browsers are you seeing the problem on?

No response

Record

  • I have read the Contributing Guidelines
  • I'm a GSSOC'24 contributor
  • I'm a GSSOC'26 contributor
  • I'm a IEEE IGDTUW contributor
  • I want to work on this issue

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions