Skip to content

fix(predict): cp-7.62.0 debounce search input in PredictSearchOverlay#24820

Merged
matallui merged 1 commit intomainfrom
predict/debounce-search
Jan 16, 2026
Merged

fix(predict): cp-7.62.0 debounce search input in PredictSearchOverlay#24820
matallui merged 1 commit intomainfrom
predict/debounce-search

Conversation

@matallui
Copy link
Copy Markdown
Contributor

@matallui matallui commented Jan 16, 2026

Description

The PredictSearchOverlay component was triggering API requests for every character typed in the search input. This caused excessive network requests and poor UX.

Solution: Added a 200ms debounce to the search query using the existing useDebouncedValue hook, which is already used throughout the codebase for similar search functionality (Bridge, Card onboarding, Trending tokens, etc.).

Changes:

  • Import and use useDebouncedValue hook in PredictSearchOverlay
  • Pass debounced query to usePredictMarketData instead of raw search query
  • Track debouncing state to show loading indicator during debounce period
  • Combined isDebouncing and isFetching states for seamless loading UX

Changelog

CHANGELOG entry: Fixed search input triggering excessive API calls in Predictions

Related issues

Fixes: https://consensyssoftware.atlassian.net/browse/PRED-486

Manual testing steps

Feature: Debounced search in Predictions

  Scenario: user types in search field
    Given user has opened the Predictions feed
    And user has tapped the search button

    When user types "bitcoin" quickly
    Then only one API request is made after typing stops
    And skeleton loaders appear while debouncing
    And search results appear after debounce completes

Screenshots/Recordings

Before

API call triggered on every keystroke (network tab shows multiple requests)

After

Single API call after 200ms debounce delay

Screen.Recording.2026-01-16.at.10.09.58.AM.mov

Pre-merge author checklist

Pre-merge reviewer checklist

  • I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed).
  • I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots.

Note

Introduces a 200ms debounce for search in PredictSearchOverlay to reduce request churn and smooth UX.

  • Integrates useDebouncedValue and routes q in usePredictMarketData to the debounced value; adds SEARCH_DEBOUNCE_MS = 200
  • Combines debouncing and fetch state into isSearchLoading to show skeleton loaders during debounce and network fetch
  • Updates tests to mock useDebouncedValue, verify debounced query usage, loading skeletons during debounce, results after debounce, and the 200ms delay contract

Written by Cursor Bugbot for commit 1e2f1df. This will update automatically on new commits. Configure here.

Add 200ms debounce to search query to prevent API calls on every keystroke.
Uses existing useDebouncedValue hook for consistency with codebase patterns.
@github-actions
Copy link
Copy Markdown
Contributor

CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes.

@metamaskbot metamaskbot added the team-predict Predict team label Jan 16, 2026
@github-actions
Copy link
Copy Markdown
Contributor

🔍 Smart E2E Test Selection

  • Selected E2E tags: SmokePredictions
  • Risk Level: low
  • AI Confidence: 95%
click to see 🤖 AI reasoning details

The changes are isolated to the Predictions feature (PredictFeed component). The modifications add a debounce mechanism to the search functionality in the PredictSearchOverlay component:

  1. PredictFeed.tsx changes:

    • Imported existing useDebouncedValue hook
    • Added 200ms debounce delay for search queries
    • Updated loading state to account for debouncing period
    • This is a UX improvement to reduce API calls during typing
  2. PredictFeed.test.tsx changes:

    • Added comprehensive unit tests for the debounce behavior
    • Tests verify the debounced query is passed to the data hook
    • Tests verify skeleton loaders display during debouncing
    • Tests verify results display after debounce completes

The changes are well-contained within the Predict feature, use an existing utility hook (useDebouncedValue), and include proper unit test coverage. No core wallet functionality, controllers, or critical paths are affected. Only SmokePredictions tag is needed to verify the Predictions feature works correctly with this enhancement.

View GitHub Actions results

@matallui matallui changed the title fix(predict): debounce search input in PredictSearchOverlay fix(predict): cp-7.62.0 debounce search input in PredictSearchOverlay Jan 16, 2026
@matallui matallui marked this pull request as ready for review January 16, 2026 17:23
@matallui matallui requested a review from a team as a code owner January 16, 2026 17:23
Copy link
Copy Markdown
Contributor

@caieu caieu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@matallui matallui enabled auto-merge January 16, 2026 17:35
@sonarqubecloud
Copy link
Copy Markdown

@matallui matallui added this pull request to the merge queue Jan 16, 2026
Merged via the queue into main with commit 9d02315 Jan 16, 2026
114 checks passed
@matallui matallui deleted the predict/debounce-search branch January 16, 2026 18:14
@github-actions github-actions bot locked and limited conversation to collaborators Jan 16, 2026
@metamaskbot metamaskbot added the release-7.63.0 Issue or pull request that will be included in release 7.63.0 label Jan 16, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

release-7.63.0 Issue or pull request that will be included in release 7.63.0 size-S team-predict Predict team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants