fix: add skipUrlUpdate prop to SearchContextProvider in SearchUI - #3182
fix: add skipUrlUpdate prop to SearchContextProvider in SearchUI#3182bra-i-am wants to merge 2 commits into
Conversation
|
Thanks for the pull request, @bra-i-am! This repository is currently maintained by Once you've gone through the following steps feel free to tag them in a comment and let them know that your changes are ready for engineering review. 🔘 Get product approvalIf you haven't already, check this list to see if your contribution needs to go through the product review process.
🔘 Provide contextTo help your reviewers and other members of the community understand the purpose and larger context of your changes, feel free to add as much of the following information to the PR description as you can:
🔘 Get a green buildIf one or more checks are failing, continue working on your changes until this is no longer the case and your build turns green. DetailsWhere can I find more information?If you'd like to get more details on all aspects of the review process for open source pull requests (OSPRs), check out the following resources: When can I expect my changes to be merged?Our goal is to get community contributions seen and reviewed as efficiently as possible. However, the amount of time that it takes to review and merge a PR can vary significantly based on factors such as:
💡 As a result it may take up to several weeks or months to complete a review and merge your PR. |
2ece33e to
e73cae1
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #3182 +/- ##
==========================================
- Coverage 95.79% 95.78% -0.01%
==========================================
Files 1398 1398
Lines 33528 33531 +3
Branches 7630 7886 +256
==========================================
Hits 32119 32119
+ Misses 1365 1353 -12
- Partials 44 59 +15 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
5933de4 to
b8c265d
Compare
When opening the global search modal (magnifying glass in the header) from a Content Library page and typing a search term, the library page's own search bar was mirroring the same input in the background.
Root cause: both the search modal and the library page use
SearchContextProvider, which by default syncs all search state to URL query params (?q=...). Since they share the same URL, typing in the modal updated?q=which the library page's search bar also reads and reflects.The fix adds
skipUrlUpdateto theSearchContextProviderinsideSearchUI(the modal's inner content), making the modal use isolatedReact.useStateinstead of URL params. The modal's search state is now fully decoupled from the page's search state.Secondary bug exposed by the fix: before adding
skipUrlUpdate,setTypesFilteruseduseStateWithUrlSearchParamwhich serializes the value viatoString()on every call; it never compares references. So mutatingTypesFilterDatain place and returning the same object worked fine: the setter only cared about the serialized string. AfterskipUrlUpdate,setTypesFilterbecame a rawReact.useStatesetter, which usesObject.is(prev, next)for change detection. Since the mutation happened on the same object and the same reference was returned,Object.isreturnedtrue→ no re-render → block type filter chips never appeared.Fixed by returning a new
TypesFilterDatainstance on every update inFilterByBlockTypeandSearchManager. The mutation bug always existed but was invisible untilskipUrlUpdateremoved the serialization layer that was masking it.Supporting information
Testing instructions
rich).Evidence