Skip to content

#5305 Fix ReferenceError: toTitleCase undefined in planet UI#5305

Merged
walterbender merged 7 commits intosugarlabs:masterfrom
Mokshii46:fix-toTitleCase-global
Jan 28, 2026
Merged

#5305 Fix ReferenceError: toTitleCase undefined in planet UI#5305
walterbender merged 7 commits intosugarlabs:masterfrom
Mokshii46:fix-toTitleCase-global

Conversation

@Mokshii46
Copy link
Contributor

@Mokshii46 Mokshii46 commented Jan 24, 2026

Fix: Resolve toTitleCase undefined error in GlobalTag.js

Summary

Fixes Uncaught ReferenceError: toTitleCase is not defined error that prevented the Planet view from loading properly by ensuring utils.js is in the correct location and loaded before dependent modules.

Problem

The Music Blocks Planet view was failing to load with the following error:

  1. GlobalTag.js calls toTitleCase() function during tag rendering
  2. utils.js (which defines toTitleCase) was not in the correct directory
  3. The server returned a 404 HTML page instead of the JavaScript file
  4. Browser refused to execute due to MIME type mismatch (text/html instead of application/javascript)
  5. This caused all Planet tags to fail rendering, breaking the entire Planet interface

Solution

Changes Made

  1. Moved utils.js to the correct directory (js/utils.js) to match the import path in index.html
  2. Verified proper script loading order (utils.js loads before GlobalTag.js)

Technical Details

  • The index.html file expects utils.js at js/utils.js
  • The file was previously located at an incorrect path
  • Moving the file ensures the browser can load it with the correct MIME type
  • The toTitleCase() function is now globally accessible when GlobalTag.js executes

Before:
6fbbcea2-1530-4c7f-90b5-4f01d0c045c3

After:

image

Testing

  • Verified utils.js loads successfully in Network tab (returns 200 OK)
  • Confirmed MIME type is application/javascript
  • No toTitleCase is not defined errors in console
  • GlobalTag renders correctly with proper title casing
  • Planet view displays all tags without errors
  • Tag selection and filtering work as expected
  • Tested on Chrome/Firefox (latest stable)

Related Issues

Fixes #5305

Checklist

  • Changes follow Sugar Labs coding standards
  • No functional changes to existing code
  • Tested locally with hard refresh (Ctrl+Shift+R)
  • Verified no console errors during page load
  • All Planet view features working correctly

@github-actions
Copy link
Contributor

❌ Some Jest tests failed. Please check the logs and fix the issues before merging.

Failed Tests:

synthutils.test.js
PitchActions.test.js
utils.test.js
rubrics.test.js

@Mokshii46
Copy link
Contributor Author

Hi!
The latest GitHub Actions run is green and all Jest tests are passing now.
This PR is ready for review.
Thanks!

@Mokshii46
Copy link
Contributor Author

Mokshii46 commented Jan 24, 2026

Hey @walterbender @omsuneri ,I have opened a PR ,please check when you get time.
Thank you!

@omsuneri
Copy link
Member

@Mokshii46 please resolve the conflicts !!

@github-actions
Copy link
Contributor

❌ Some Jest tests failed. Please check the logs and fix the issues before merging.

Failed Tests:

synthutils.test.js
PitchActions.test.js
abc.test.js
utils.test.js
rubrics.test.js

@github-actions
Copy link
Contributor

❌ Some Jest tests failed. Please check the logs and fix the issues before merging.

Failed Tests:

abc.test.js

@Mokshii46
Copy link
Contributor Author

@omsuneri Changes done.Please review it again.

@walterbender
Copy link
Member

Why do we need to define the function twice? Why cannot we use the version in js/utils/utils.js from the planet code?

@github-actions
Copy link
Contributor

❌ Some Jest tests failed. Please check the logs and fix the issues before merging.

Failed Tests:

abc.test.js

@github-actions
Copy link
Contributor

❌ Some Jest tests failed. Please check the logs and fix the issues before merging.

Failed Tests:

synthutils.test.js
PitchActions.test.js
abc.test.js
utils.test.js

@github-actions
Copy link
Contributor

❌ Some Jest tests failed. Please check the logs and fix the issues before merging.

Failed Tests:

abc.test.js

@github-actions
Copy link
Contributor

❌ Some Jest tests failed. Please check the logs and fix the issues before merging.

Failed Tests:

abc.test.js

@Mokshii46
Copy link
Contributor Author

You are right!!
I’ve updated js/utils/utils.js so toTitleCase is shared between Planet and core utils without duplicating code or overwriting existing exports.
All tests are passing now.
@walterbender @omsuneri

@walterbender walterbender merged commit 80c54ba into sugarlabs:master Jan 28, 2026
5 of 6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants