Skip to content

Search/autocomplete not initializing correctly after jQuery is deferred #4954

@Ashish-Rautela

Description

@Ashish-Rautela

Description

Search/autocomplete is currently not initializing correctly on the main branch of Music Blocks. There is no obvious UI error, so this issue can easily go unnoticed, but the search functionality does not work as expected.

I investigated this using git bisect and traced the first occurrence to commit 01cee2a (PR #4828 ), which introduced deferred loading of jQuery for performance and accessibility improvements. The PR itself is valid, but it exposed fragile assumptions in the existing search initialization logic.

Expected Behavior

Search/autocomplete should initialize correctly on page load.
Typing in the search field should show suggestions and allow selecting blocks as before.

How to Reproduce

  • Check out the current main branch.
  • Open Music Blocks in a browser.
  • Try using the search/autocomplete input.
  • Observe that search suggestions do not appear and search does not function.
  • Console log Errors:
    Uncaught ReferenceError: $ is not defined

This occurs because search initialization relies on global $ and inline execution order.

Environment:

Operating System: Windows 10
Browser : Chrome
Version of Software/Project: current main branch

Checklist

  • I have read and followed the project's code of conduct.
  • I have searched for similar issues before creating this one.
  • I have provided all the necessary information to understand and reproduce the issue.
  • I am willing to contribute to the resolution of this issue.

Thank you for contributing to our project! We appreciate your help in improving it.

I also opened a small PR that temporarily restores non-deferred jQuery to unblock search while a proper refactor of search initialization is discussed. That PR is intentionally marked as a temporary workaround, not a long-term solution.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions