Feature/partner-search: fix search box debounce and guard precedence - #4346
Feature/partner-search: fix search box debounce and guard precedence#4346Joker666 wants to merge 16 commits into
Conversation
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.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
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. Comment |
…box-debounce-and-precedence
014fafc to
90b7036
Compare
7efc41e to
61ee234
Compare
…box-debounce-and-precedence
…box-debounce-and-precedence
…box-debounce-and-precedence
…box-debounce-and-precedence
817d7e5 to
cb8fa4a
Compare
d06d7f8 to
8815bbb
Compare
…box-debounce-and-precedence
4c19691 to
7605a40
Compare
d1687c8 to
bd5e962
Compare
…box-debounce-and-precedence
…box-debounce-and-precedence
…box-debounce-and-precedence
…box-debounce-and-precedence
…box-debounce-and-precedence
…box-debounce-and-precedence
…box-debounce-and-precedence
…box-debounce-and-precedence
…box-debounce-and-precedence
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 readx ?? ("" !== 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:
Firing calls
queryParamswithdel: ["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 tototalSaleAmountorder.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
#4316described 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.