Skip to content

Fix ReferenceError when doSearch is not yet available#5314

Closed
Kunal241207 wants to merge 1 commit intosugarlabs:masterfrom
Kunal241207:fix-dosearch-referenceerror
Closed

Fix ReferenceError when doSearch is not yet available#5314
Kunal241207 wants to merge 1 commit intosugarlabs:masterfrom
Kunal241207:fix-dosearch-referenceerror

Conversation

@Kunal241207
Copy link
Contributor

This PR fixes a ReferenceError that occurs when doSearch() is invoked
before it is available on page load.

In some load orders, doSearch is defined later (e.g. under
window.activity), causing the initial call in $(document).ready()
to fail and stop further script execution.

The fix safely checks for doSearch in both locations before calling
it, preventing the error while preserving existing behavior.

Fixes #5313

@github-actions
Copy link
Contributor

✅ All Jest tests passed! This PR is ready to merge.

@kartikktripathi
Copy link
Contributor

Hey, I tested your changes and looked through the code. Everything looks good to me.
Thanks for the contribution!

@Kunal241207
Copy link
Contributor Author

Thanks a lot for the review!
Since the checks have passed, could a maintainer with write access please approve/merge when convenient?

@kartikktripathi
Copy link
Contributor

Right, there's a load of other PRs open right now, hope yours will be checked and merged soon.

Copy link
Contributor

@Ashish-Rautela Ashish-Rautela left a comment

Choose a reason for hiding this comment

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

Search is not working after the changes

@kartikktripathi
Copy link
Contributor

kartikktripathi commented Jan 31, 2026

Thanks for flagging this, good catch. I re-tested, and it looks like the new guard prevents the ReferenceError but can also skip initialising search entirely when doSearch isn’t available yet.

@Kunal241207
Copy link
Contributor Author

Closing this PR since the issue has been resolved in #5676. Thank you!

@Kunal241207 Kunal241207 deleted the fix-dosearch-referenceerror branch February 14, 2026 19:24
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.

[Bug] ReferenceError during startup when doSearch is not defined

3 participants