Skip to content

Feature/partner-search: fix search box debounce and guard precedence - #4346

Open
Joker666 wants to merge 16 commits into
feature/partner-full-text-search-syncfrom
fix/search-box-debounce-and-precedence
Open

Feature/partner-search: fix search box debounce and guard precedence#4346
Joker666 wants to merge 16 commits into
feature/partner-full-text-search-syncfrom
fix/search-box-debounce-and-precedence

Conversation

@Joker666

Copy link
Copy Markdown
Collaborator

Fix the search box debounce and guard precedence

Stacked on #4343. Three pre-existing defects in SearchBoxPersisted, called out but deliberately left alone in #4316 because they change behaviour for all 20 consumers.

Guard precedence, in two places

!== binds tighter than ??, so both guards read x ?? ("" !== y) rather than (x ?? "") !== y. That evaluates to the param itself whenever one is present, which is always truthy, so neither guard ever skipped.

The visible consequence is on mount:

?search=foo&sortBy=relevance    guard: "foo" ?? ("" !== "foo")  ->  "foo"  (fires)
                                fixed: ("foo") !== "foo"        ->  false  (skips)

Firing calls queryParams with del: ["page", ...resetParamsOnChange]. On the partners table that list is ["sortBy", "sortOrder"], so opening a shared relevance-sorted search link stripped the sort before the user touched anything and the results quietly fell back to totalSaleAmount order.

Clear button never cancelled the debounce

Clearing notifies immediately, but a keystroke still waiting out the 500ms landed afterwards and restored the term that was just cleared. Now cancelled first.

Notes

#4316 described this as two bugs. The precedence one is in two places, and the consumer count there is 20 files rather than 63.

No tests. This repo has no DOM environment and no component tests, so adding that setup would be a larger and more debatable change than the fix. Happy to do it separately if wanted.

Three defects in SearchBoxPersisted, all pre-existing.

`!==` binds tighter than `??`, so both guards read `x ?? ("" !== y)` rather
than `(x ?? "") !== y`. That evaluates to the param itself whenever one is
present, which is always truthy, so neither guard ever skipped.

The visible consequence is on mount. Any URL carrying the search param fired
the effect immediately and called queryParams with `del: ["page",
...resetParamsOnChange]`, so opening a shared partner search link with
sortBy=relevance stripped the sort before the user touched anything.

The clear button also never cancelled the pending debounce. It notifies
immediately, so a keystroke still waiting out the 500ms landed afterwards and
restored the term that was just cleared.

No tests: this repo has no DOM environment and no component tests, and adding
that setup is a larger change than the fix.
@vercel

vercel Bot commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
dub Ready Ready Preview Aug 26, 2026 6:30pm

Request Review

@coderabbitai

coderabbitai Bot commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 72ff6aa0-269d-4494-a127-980e5dca4162

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@Joker666
Joker666 force-pushed the feature/partner-full-text-search-sync branch from 014fafc to 90b7036 Compare August 17, 2026 22:03
@Joker666
Joker666 force-pushed the fix/search-box-debounce-and-precedence branch from 7efc41e to 61ee234 Compare August 17, 2026 22:03
@Joker666
Joker666 force-pushed the feature/partner-full-text-search-sync branch from 4c19691 to 7605a40 Compare August 18, 2026 01:55
@Joker666
Joker666 force-pushed the fix/search-box-debounce-and-precedence branch from d1687c8 to bd5e962 Compare August 18, 2026 01:55
@Joker666 Joker666 changed the title Fix the search box debounce and guard precedence Feature/partner-search: fix search box debounce and guard precedence Aug 26, 2026
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.

1 participant