From 659c84a0f5bf30ba6baab371ac0aa98b1935fc3b Mon Sep 17 00:00:00 2001 From: Aqib Nawab Date: Wed, 18 Nov 2026 11:12:01 +0500 Subject: [PATCH] Fix the learning log render loop and fold the preview project goal LearningLog defaulted initialAnswers to a new {} on every render, and it compares that prop with the previous value during render. With no saved answers (the instructor preview has none) it re-rendered until React gave up, so every checklist showed 'This block could not be displayed'. The default is now one shared object. The instructor preview showed the course project goal in an open box above every lesson. It is now the same collapsed 'Project overview' that the learner reader uses. --- frontend/src/components/teach/course-preview-shell.tsx | 8 ++++---- .../learning-ui/src/components/learn/learning-log.tsx | 5 ++++- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/frontend/src/components/teach/course-preview-shell.tsx b/frontend/src/components/teach/course-preview-shell.tsx index c36e1ca9..1f0696ce 100644 --- a/frontend/src/components/teach/course-preview-shell.tsx +++ b/frontend/src/components/teach/course-preview-shell.tsx @@ -860,10 +860,10 @@ export function CoursePreviewShell({ ) : null} {course.projectGoal ? ( -

- The project: - {course.projectGoal.trim().replace(/\.+$/, "")}. -

+
+ Project overview +

{course.projectGoal.trim().replace(/\.+$/, "")}.

+
) : null} {activeChapter.isMilestone ? ( diff --git a/packages/learning-ui/src/components/learn/learning-log.tsx b/packages/learning-ui/src/components/learn/learning-log.tsx index 6424249b..466e273a 100644 --- a/packages/learning-ui/src/components/learn/learning-log.tsx +++ b/packages/learning-ui/src/components/learn/learning-log.tsx @@ -109,12 +109,15 @@ function LearningLogQuestion({ ); } +/** One shared object, so the default never looks like new data on every render. */ +const NO_INITIAL_ANSWERS: LearningLogAnswers = {}; + export function LearningLog({ title = "Share what you learned", instruction, questions, variant = "default", - initialAnswers = {}, + initialAnswers = NO_INITIAL_ANSWERS, onSave, }: { title?: string;