Skip to content

fix(ProjectService): New unit page throws because isDefaultLocale() reads a project that is not loaded - #2379

Merged
hirokiterashima merged 1 commit into
WISE-Community:developfrom
Isaries:fix/default-locale-without-project
Nov 16, 2026
Merged

hirokiterashima merged 1 commit into
WISE-Community:developfrom
Isaries:fix/default-locale-without-project

Conversation

@Isaries

@Isaries Isaries commented Nov 15, 2026

Copy link
Copy Markdown
Contributor

Opening the authoring tool's new unit page (/teacher/edit/new-unit) logs TypeError: Cannot read properties of null (reading 'metadata') in the console. AuthoringToolComponent calls ProjectService.isDefaultLocale() on every UI change to decide whether elements should be disabled while a translation is being edited. That method has called getLocale() since the multilingual units feature (#1617), and getLocale() reads this.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() returns true when 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

  • New case in projectService.spec.ts: with service.project = null, isDefaultLocale() returns true. Against the current develop it fails with TypeError: Cannot read properties of null (reading 'metadata').
  • projectService.spec.ts, all specs under authoringTool, and teacherProjectTranslationService.spec.ts pass (179).

…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.

@hirokiterashima hirokiterashima left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

@hirokiterashima
hirokiterashima merged commit 2cf769b into WISE-Community:develop Nov 16, 2026
3 of 4 checks passed
@hirokiterashima

Copy link
Copy Markdown
Member

🎉 This PR is included in version 5.251.2 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants