Skip to content

Conversation

@SherylMehta1
Copy link
Contributor

This PR fixes a set of load-order issues causing early-initialization errors in the console:

  • doSearch is not defined
  • Cannot read properties of undefined (reading 'idInput_custom')
  • Race conditions between index.html scripts and RequireJS loading

What this PR changes

  • Replaces early $(document).ready() execution of doSearch() with a safe post-initialization event listener.

  • Introduces a custom "mb-ready" event dispatched from Activity once all dependencies and UI elements are available.

  • Moves search initialization to this new lifecycle point:

    document.addEventListener("mb-ready", function () {
        doSearch();
    });

Why:

  • Prevents doSearch() from running before Activity, palettes, toolbar, and search DOM nodes are ready.
  • Eliminates noisy console errors without altering any user-visible behavior.
  • Aligns Music Blocks initialization with its RequireJS-based module loading sequence.
  • Keeps the change minimal, targeted, and low-risk.

Testing:

  • Confirm no doSearch is not defined error appears.
  • Confirm no idInput_custom undefined error appears.
  • Confirm Activity loads normally and the UI behaves identically.
  • Confirm search still works as expected after full load.

Next steps:

  • Resolve remaining module-order warnings.
  • Address duplicate script loading (e.g., gif-animator.js).
  • Improve Tone.js user-gesture initialization to reduce AudioContext warnings.
  • Prepare for a later PR to organize script/module loading before ES module migration.

@github-actions
Copy link
Contributor

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

@vyagh
Copy link
Contributor

vyagh commented Dec 30, 2025

Hey,
i checked the CI logs and saw the prettier check is failing on js/activity.js. looks like a small formatting difference (an extra blank line).
You can verify and fix it locally by running:

npx prettier --write js/activity.js

@github-actions
Copy link
Contributor

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

@github-actions
Copy link
Contributor

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

@github-actions
Copy link
Contributor

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

@SherylMehta1
Copy link
Contributor Author

Hey, i checked the CI logs and saw the prettier check is failing on js/activity.js. looks like a small formatting difference (an extra blank line). You can verify and fix it locally by running:

npx prettier --write js/activity.js

Hey, thanks for the pointer!
The failure was due to the linter workflow picking up deleted and unrelated files. I’ve updated the workflow to diff from the PR merge-base and ignore deleted files, so ESLint/Prettier now run only on files actually changed in the PR. CI is green now.

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.

2 participants