Skip to content

Fix crash when viewing problem set content list while not logged in#2916

Open
cqnykamp wants to merge 1 commit into
mainfrom
claude/modest-franklin-YXZSI
Open

Fix crash when viewing problem set content list while not logged in#2916
cqnykamp wants to merge 1 commit into
mainfrom
claude/modest-franklin-YXZSI

Conversation

@cqnykamp

Copy link
Copy Markdown
Contributor

Summary

Fixes #2788 — "Broken: view inside problem set when not logged in"

  • Root cause: In CompoundActivityEditor, the "Add" menu JSX was always rendered, including a <MenuItem to={/activities/${user!.userId}}> that eagerly evaluated user!.userId. When user is undefined (not logged in), this throws Cannot read properties of undefined (reading 'userId') — even though the <MenuButton> was hidden via hidden={readOnlyStructure}.

  • Fix: Replace hidden={readOnlyStructure} on the MenuButton with {!readOnlyStructure && <Menu>...</Menu>} wrapping the entire menu, so the JSX (and user!.userId) is never evaluated when the structure is read-only. Also guard the ActivateAuthorMode modal to only render when user is defined.

Test plan

  • Added e2e test: activityViewer.cy.ts — "can view content list of problem set when not logged in"
    • Creates a public sequence with a child document as an author user
    • Clears cookies (logs out)
    • Visits the activityViewer for the sequence
    • Clicks the Edit Mode Button (previously crashed)
    • Asserts the Activities list renders with the child document
    • Asserts the "Add" button is NOT present (read-only for non-logged-in users)

https://claude.ai/code/session_012L3AUuFDfGTspJMf9W7Sf2


Generated by Claude Code

When a logged-out user clicked the edit mode button on a sequence
(problem set) in the activity viewer, the CompoundActivityEditor
would crash with "Cannot read properties of undefined (reading
'userId')" because the Add menu JSX eagerly evaluated `user!.userId`
even though the menu button was hidden via `hidden={readOnlyStructure}`.

Fix by wrapping the entire Add menu in `{!readOnlyStructure && ...}`
so the JSX (and user!.userId) is never evaluated when the menu can't
be shown. Also guard the ActivateAuthorMode modal to only render when
user is defined.

Closes #2788

https://claude.ai/code/session_012L3AUuFDfGTspJMf9W7Sf2

Copy link
Copy Markdown
Contributor Author

@cqnykamp — requesting your review on this PR. It fixes #2788.


Generated by Claude Code

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.

Broken: view inside problem set when not logged in

2 participants