Skip to content

Improve catalog filter behavior when min price exceeds max price - #134

Merged
manoahLinks merged 2 commits into
mind-vault-1:mainfrom
noevidence1017:feat/catalog-invalid-price-range
Jul 29, 2026
Merged

Improve catalog filter behavior when min price exceeds max price#134
manoahLinks merged 2 commits into
mind-vault-1:mainfrom
noevidence1017:feat/catalog-invalid-price-range

Conversation

@noevidence1017

Copy link
Copy Markdown
Contributor

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

  • Min above max: both price inputs get a danger-coloured border, an inline message appears under them - "Minimum price is higher than maximum price. The price filter is off until you fix the range." - and the price filter is not applied. Search, verification and type filters keep working, so the list shows their result rather than going blank.
  • Min equal to max: valid, applied as an exact-price match (bounds are inclusive, unchanged).
  • One side only, blank fields, or non-numeric text: unchanged from before.
  • Any valid range: unchanged from before, including dropping resources whose price is not numeric while a bound is applied.
  • "Clear filters" stays enabled while the range is invalid, so the existing one-tap recovery still works.

Changes

src/utils/priceRange.ts (new)

  • parsePriceRange(minPrice, maxPrice) returns the parsed bounds plus isInvalid (both bounds set and min > max) and isActive (has a bound and is valid).
  • filterByPriceRange(items, range) applies an active range and returns the list untouched otherwise.
  • INVALID_PRICE_RANGE_MESSAGE is exported so the message has a single source.

src/screens/CatalogScreen.tsx

  • The inline min/max parsing in the filteredResources memo is replaced by these helpers; the filtering logic itself is carried over unchanged.
  • Invalid-state styling on both price inputs, plus an inline error Text with accessibilityRole="alert" and accessibilityLiveRegion="polite" so screen readers announce it; each input also carries the message as its accessibilityHint while invalid.
  • Both new styles are theme-driven (colors.danger), so they work in light and dark mode.

src/utils/priceRange.test.ts (new)

  • Covers blank and non-numeric fields, single-sided ranges, min equal to max, the inverted range being flagged invalid and inactive, inclusive bounds, and non-numeric prices.

Backend assumptions

None. Price filtering is entirely client-side on the already-fetched catalog, as before - buildQuery does not send price parameters, and no request is made or changed by this PR.

Verification

  • npm run typecheck passes.
  • Manual verification (catalog with resources priced 1.00 / 5.00 / 10.00): entering min 10 and max 5 shows the two highlighted inputs and the inline message while the list keeps showing all three resources and the "Showing 3 of 3" counter; clearing the max, or lowering the min to 5, removes the message and applies the range again; "Clear filters" resets both fields. No screenshots attached - this was exercised against the extracted filter logic and by walking the render path, since I have no simulator plus a running MindVault server in this environment.
  • Unit tests: the repo's npm test currently fails for every suite on main, before this change (TypeError: this._moduleMocker.clearMocksOnScope is not a function - the jest-runtime@30.4.1 override in package.json is paired with jest-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 under npm test unchanged once the jest versions are reconciled.

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.
@drips-wave

drips-wave Bot commented Jul 28, 2026

Copy link
Copy Markdown

@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! 🚀

Learn more about application limits

@manoahLinks
manoahLinks merged commit 0d39827 into mind-vault-1:main Jul 29, 2026
1 of 2 checks passed
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.

Improve catalog filter behavior when min price exceeds max price

2 participants