Skip to content

[bug] SearchForm loading state never resets after navigation #32

@pragnyanramtha

Description

@pragnyanramtha

Bug Description

The SearchForm component sets isLoading to true when the user submits a search, but never resets it to false after navigation completes.

Location

frontend/app/components/SearchForm.tsx (lines 17-19)

Current Behavior

const handleSearch = (e: React.FormEvent) => {
  e.preventDefault();
  if (!query.trim()) return;
  setIsLoading(true);  // Set to true
  router.push(`/search?q=${encodeURIComponent(query.trim())}`);
  // Never set back to false!
};

Expected Behavior

The loading spinner should not persist forever. Since navigation happens immediately via router.push(), the isLoading state is unnecessary OR should be reset after navigation.

Suggested Fix

Either:

  1. Remove the isLoading state entirely (since navigation is immediate)
  2. Or use useEffect to reset the state after route change

Impact

  • Loading spinner shows forever after search
  • Search button remains disabled after navigation
  • Poor user experience

Labels

bug, frontend, good first issue

Metadata

Metadata

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions