Improve catalog filter behavior when min price exceeds max price - #134
Merged
manoahLinks merged 2 commits intoJul 29, 2026
Merged
Conversation
Entering a minimum above the maximum produced an unexplained empty catalog: the filter kept applying, so every resource was dropped and the only clue was a "No matches" state that did not say which filter was at fault. The min/max parsing and filtering now live in a small pure helper. An inverted range is reported as invalid and treated as inactive, so the list keeps showing the results of the remaining filters instead of emptying, and the catalog screen marks both price inputs and renders an inline message explaining that the price filter is off until the range is corrected. Valid ranges, single-sided ranges and blank fields behave exactly as before.
|
@noevidence1017 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
closes #68
Summary
On the catalog screen, typing a minimum price above the maximum kept the price filter active. Since no resource can satisfy an inverted range, the list emptied and the user saw only the generic "No matches / Try adjusting or clearing your filters" state, with nothing pointing at the price fields as the cause.
The invalid range is now detected and given both parts of what the issue asks for: clear inline feedback, and predictable disabled-filter behaviour.
Behaviour
Changes
src/utils/priceRange.ts(new)parsePriceRange(minPrice, maxPrice)returns the parsed bounds plusisInvalid(both bounds set and min > max) andisActive(has a bound and is valid).filterByPriceRange(items, range)applies an active range and returns the list untouched otherwise.INVALID_PRICE_RANGE_MESSAGEis exported so the message has a single source.src/screens/CatalogScreen.tsxfilteredResourcesmemo is replaced by these helpers; the filtering logic itself is carried over unchanged.TextwithaccessibilityRole="alert"andaccessibilityLiveRegion="polite"so screen readers announce it; each input also carries the message as itsaccessibilityHintwhile invalid.colors.danger), so they work in light and dark mode.src/utils/priceRange.test.ts(new)Backend assumptions
None. Price filtering is entirely client-side on the already-fetched catalog, as before -
buildQuerydoes not send price parameters, and no request is made or changed by this PR.Verification
npm run typecheckpasses.npm testcurrently fails for every suite onmain, before this change (TypeError: this._moduleMocker.clearMocksOnScope is not a function- thejest-runtime@30.4.1override inpackage.jsonis paired withjest-expo@52, which brings a jest 29 environment). That pre-existing toolchain mismatch is left alone to keep this PR scoped. The new suite was run against the same source with a config that only swaps in a node test environment: 9 tests, all passing. It will run undernpm testunchanged once the jest versions are reconciled.