Skip to content

Reflect market filters in URL and announce result counts - #968

Merged
greatest0fallt1me merged 1 commit into
Predictify-org:mainfrom
Fading-Dev:feat/markets-url-filters-live-region-965
Oct 1, 2026
Merged

greatest0fallt1me merged 1 commit into
Predictify-org:mainfrom
Fading-Dev:feat/markets-url-filters-live-region-965

Conversation

@Fading-Dev

Copy link
Copy Markdown
Contributor

Overview

The search and category filters on /markets lived only in component state, so a filtered view
could not be shared, bookmarked or restored with the Back button, and the FWC26 campaign links lost
their filter context. Nothing announced the filtered result count to screen-reader users.

Both filters now round-trip through the query string — debounced so typing writes one history entry
per pause rather than one per keystroke — the state hydrates from the URL on load with category
validated against the known list, and each change in result count produces a single polite
live-region announcement through the existing useGlobalLiveRegion hook.

Related Issue

Closes #965

Changes

URL as the source of truth

  • [MODIFY] app/markets/page.tsx
    • useSearchParams() now hydrates search and category on mount, so
      /markets?q=argentina&category=Football pre-fills both controls and filters the list.
    • An unknown or missing category falls back to all via an isKnownCategory guard instead of
      filtering to an empty grid.
    • router.replace (not push) writes ?q= / ?category= after a 300 ms debounce, so a typing
      session does not add a history entry per keystroke and Back leaves the filtered view intact.
    • The filter state moved behind a React.Suspense boundary, which useSearchParams() opts the
      route into, so the shell still prerenders.

Announcements

  • [MODIFY] app/markets/page.tsx
    • Announces N markets found politely through useGlobalLiveRegion() after filtering,
      deduplicating identical counts so re-renders do not repeat the message.
    • NoMatchEmptyState's clear action resets both the component state and the URL.

Tests

  • [MODIFY] app/markets/__tests__/page.test.tsx
    • Covers URL hydration of both controls, the invalid-category fallback, the debounced replace
      write, the announcement payload and the clear-button reset.

Verification Results

Static review only — no clone or sandbox is available in this environment, so `pnpm test
app/markets` and `pnpm test hooks/__tests__` were NOT executed and no pass is claimed.
- The debounce timer is cleared on unmount, and the URL write uses `replace`, so the history
  criterion is enforced by construction.
- Announcements are deduplicated by comparing against the last announced count.
Acceptance Criteria Status
Typing a search updates ?q= in the URL without adding a history entry per keystroke ✅ 300 ms debounce + router.replace
Loading /markets?q=argentina&category=Football pre-fills both controls and filters the list ✅ state initialised from useSearchParams()
An invalid category param falls back to all ✅ isKnownCategory guard against the CATEGORIES list
Each change in result count triggers one polite live-region announcement ✅ useGlobalLiveRegion() with duplicate-count suppression
app/markets/__tests__/page.test.tsx covers URL hydration and the announcement ✅ tests extended; ⚠️ not executed locally

Closes #965

@vercel

vercel Bot commented Sep 27, 2026

Copy link
Copy Markdown

@Fading-Dev is attempting to deploy a commit to the Jagadeesh B's projects Team on Vercel.

A member of the Team first needs to authorize it.

@drips-wave

drips-wave Bot commented Sep 27, 2026

Copy link
Copy Markdown

@Fading-Dev 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

@greatest0fallt1me
greatest0fallt1me merged commit 45aa0d8 into Predictify-org:main Oct 1, 2026
1 check failed
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.

Reflect market filters in URL and announce result counts

2 participants