Repository navigation
fix(ProjectService): New unit page throws because isDefaultLocale() reads a project that is not loaded - #2379
Merged
hirokiterashima merged 1 commit intoNov 16, 2026
Conversation
…eads a project that is not loaded AuthoringToolComponent calls isDefaultLocale() on every UI change to decide whether to disable elements for translation. On the new unit page no project has been loaded yet, so getLocale() reads metadata from a null project and throws "Cannot read properties of null (reading 'metadata')". isDefaultLocale() now returns true when there is no project, since there is nothing to translate.
Member
|
🎉 This PR is included in version 5.251.2 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Opening the authoring tool's new unit page (
/teacher/edit/new-unit) logsTypeError: Cannot read properties of null (reading 'metadata')in the console.AuthoringToolComponentcallsProjectService.isDefaultLocale()on every UI change to decide whether elements should be disabled while a translation is being edited. That method has calledgetLocale()since the multilingual units feature (#1617), andgetLocale()readsthis.project.metadata, but on the new unit page no project has been loaded yet.Nothing visible breaks, but the error is raised on every UI change on that page, which makes real errors there harder to notice.
Changes
isDefaultLocale()returnstruewhen no project is loaded: with no project there is nothing to translate, so the page behaves as it does for a unit in its default language.Test
projectService.spec.ts: withservice.project = null,isDefaultLocale()returnstrue. Against the currentdevelopit fails withTypeError: Cannot read properties of null (reading 'metadata').projectService.spec.ts, all specs underauthoringTool, andteacherProjectTranslationService.spec.tspass (179).