Skip to content

fix: add skipUrlUpdate prop to SearchContextProvider in SearchUI - #3182

Open
bra-i-am wants to merge 2 commits into
openedx:masterfrom
eduNEXT:bc/fix-search-modal-and-library-things
Open

fix: add skipUrlUpdate prop to SearchContextProvider in SearchUI#3182
bra-i-am wants to merge 2 commits into
openedx:masterfrom
eduNEXT:bc/fix-search-modal-and-library-things

Conversation

@bra-i-am

@bra-i-am bra-i-am commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

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 skipUrlUpdate to the SearchContextProvider inside SearchUI (the modal's inner content), making the modal use isolated React.useState instead 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, setTypesFilter used useStateWithUrlSearchParam which serializes the value via toString() on every call; it never compares references. So mutating TypesFilterData in place and returning the same object worked fine: the setter only cared about the serialized string. After skipUrlUpdate, setTypesFilter became a raw React.useState setter, which uses Object.is(prev, next) for change detection. Since the mutation happened on the same object and the same reference was returned, Object.is returned true → no re-render → block type filter chips never appeared.

Fixed by returning a new TypesFilterData instance on every update in FilterByBlockType and SearchManager. The mutation bug always existed but was invisible until skipUrlUpdate removed the serialization layer that was masking it.

Supporting information

Testing instructions

  1. Open Studio and navigate to a Content Library.
  2. Open a Collection so the collection search bar is visible.
  3. Click the magnifying glass icon in the header to open the global search modal.
  4. Type a search term in the modal (e.g. rich).
  5. Verify the collection page's search bar in the background does not change.
  6. Close the modal and confirm the collection search bar is still empty/unchanged.
  7. Confirm the modal still searches correctly (results update as you type).
  8. Confirm block type filters (Type dropdown) still work correctly inside the modal.

Evidence

image

@openedx-webhooks

Copy link
Copy Markdown

Thanks for the pull request, @bra-i-am!

This repository is currently maintained by @bradenmacdonald.

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 approval

If you haven't already, check this list to see if your contribution needs to go through the product review process.

  • If it does, you'll need to submit a product proposal for your contribution, and have it reviewed by the Product Working Group.
    • This process (including the steps you'll need to take) is documented here.
  • If it doesn't, simply proceed with the next step.
🔘 Provide context

To 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:

  • Dependencies

    This PR must be merged before / after / at the same time as ...

  • Blockers

    This PR is waiting for OEP-1234 to be accepted.

  • Timeline information

    This PR must be merged by XX date because ...

  • Partner information

    This is for a course on edx.org.

  • Supporting documentation
  • Relevant Open edX discussion forum threads
🔘 Get a green build

If one or more checks are failing, continue working on your changes until this is no longer the case and your build turns green.

Details
Where 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:

  • The size and impact of the changes that it introduces
  • The need for product review
  • Maintenance status of the parent repository

💡 As a result it may take up to several weeks or months to complete a review and merge your PR.

@openedx-webhooks openedx-webhooks added the open-source-contribution PR author is not from Axim or 2U label Jul 28, 2026
@github-project-automation github-project-automation Bot moved this to Needs Triage in Contributions Jul 28, 2026
@bra-i-am
bra-i-am requested a review from bradenmacdonald July 28, 2026 20:22
@bra-i-am
bra-i-am force-pushed the bc/fix-search-modal-and-library-things branch from 2ece33e to e73cae1 Compare July 28, 2026 21:22
@mphilbrick211 mphilbrick211 moved this from Needs Triage to Ready for Review in Contributions Jul 28, 2026
@codecov

codecov Bot commented Jul 29, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.78%. Comparing base (27f1218) to head (b8c265d).

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

open-source-contribution PR author is not from Axim or 2U

Projects

Status: Ready for Review

Development

Successfully merging this pull request may close these issues.

TC-00328: Course search modal updates the Content Library search input in the background

3 participants