Rules Hub
Coding Rules Library
← Back to all rules
Rule priority, scope & exceptions
Use this to align rules with the senior-level structure (P0/P1/P2, scope, exceptions/tradeoffs).
frontend ruleP1universalStack: react
uxsearchedge-casesloading-state
Handle empty query and empty results in search UIs
When clearing a search input, ensure results close (check query length, not just hasData), and show an explicit message plus a loading indicator while a search is in progress.
PR: frontpage-web · org-mining-hist-2026-06Created: Jun 18, 2026
Bad example
Old codetsx
| 1 | {hasData && <Results items={items} />} |
Explanation (EN)
Objašnjenje (HR)
Good example
New codetsx
| 1 | {hasData && query.length > 0 && <Results items={items} />} |
| 2 | {isSearching && <Spinner />} |
| 3 | {!items.length && query && <NoResults />} |
Explanation (EN)
Objašnjenje (HR)