Skip to content

fix: stop instructions preview lingering above edit/view tabs - #1565

Merged
maxelkins merged 1 commit into
mainfrom
fix/1650-instructions-preview-above-tabs
Jul 31, 2026
Merged

fix: stop instructions preview lingering above edit/view tabs#1565
maxelkins merged 1 commit into
mainfrom
fix/1650-instructions-preview-above-tabs

Conversation

@maxelkins

@maxelkins maxelkins commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

🤖 Generated with AI (Claude Code)
👨‍💻 Reviewed and steered by @maxelkins

Summary

  • Educators saw a stray rendered copy of the instructions above the Edit/View tabs.
  • On refresh the panel renders read-only instructions (injected via innerHTML) before the teacher role resolves, then swaps to the editable tabs.
  • React reused the same <div> for both branches, leaving the injected markup stranded above the tabs.
  • Keying the two branch divs forces a remount so the stale content is removed.

Fixes RaspberryPiFoundation/digital-editor-issues#1650

Changes

  • Add distinct key props to the read-only and editable-tabs branch divs so React remounts instead of reusing the node.
  • Add a regression test covering the instructionsEditable false → true transition.

Note on fix

  • This is a minimal fix, it gives the two renders distinct identity without disturbing the Prism/scratchblocks pipeline that relies on imperative innerHTML.
  • It does treat a symptom of a deeper problem: read-only (Projects site instructions) and editable instructions (Code Classroom) share one component, one stepContent ref, and one imperative innerHTML effect in the same JSX slot. That combination is what let React reuse the node.
  • In the future though we may want two different components that are used in the instruction panel - ReadOnlyInstructions / EditableInstructions.

Screenshots

To be added.

Educators load a saved project before their teacher role resolves, so the
read-only instructions render (injected via innerHTML) before the editable
tabs replace them. React reused the same div for both branches, leaving the
injected markup stranded above the tabs. Keying the two branch divs forces a
remount so the stale content is removed.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

@cocomarine cocomarine left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

@maxelkins
maxelkins merged commit be70cbe into main Jul 31, 2026
9 checks passed
@maxelkins
maxelkins deleted the fix/1650-instructions-preview-above-tabs branch July 31, 2026 12:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants