Skip to content

Fix search bar disappearing when no products match query#1

Open
285729101 wants to merge 1 commit into
mainfrom
fix/search-bar-disappearing
Open

Fix search bar disappearing when no products match query#1
285729101 wants to merge 1 commit into
mainfrom
fix/search-bar-disappearing

Conversation

@285729101

Copy link
Copy Markdown
Owner

Fixes antiwork#3262

The search bar and tables were conditionally rendered based on current products.length, so when a search returned zero results the search bar would vanish and the table's useEffect (which triggers Inertia reloads on query change) would stop running. The user gets stuck with no way to search again.

The fix uses useRef to remember whether products/memberships existed on initial page load. The search bar stays visible as long as there were initial items or there's an active query, and the table components stay mounted so their search effects keep firing. No changes needed in the table components themselves since their hooks run before the early return.

Added a system test that searches for a nonexistent product, verifies the search bar persists, then clears the search and confirms products reappear.

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.

Search bar disappears when no products match the search query

1 participant