Fix crash when viewing problem set content list while not logged in#2916
Open
cqnykamp wants to merge 1 commit into
Open
Fix crash when viewing problem set content list while not logged in#2916cqnykamp wants to merge 1 commit into
cqnykamp wants to merge 1 commit into
Conversation
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
Contributor
Author
|
@cqnykamp — requesting your review on this PR. It fixes #2788. Generated by Claude Code |
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.
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 evaluateduser!.userId. Whenuserisundefined(not logged in), this throwsCannot read properties of undefined (reading 'userId')— even though the<MenuButton>was hidden viahidden={readOnlyStructure}.Fix: Replace
hidden={readOnlyStructure}on theMenuButtonwith{!readOnlyStructure && <Menu>...</Menu>}wrapping the entire menu, so the JSX (anduser!.userId) is never evaluated when the structure is read-only. Also guard theActivateAuthorModemodal to only render whenuseris defined.Test plan
activityViewer.cy.ts— "can view content list of problem set when not logged in"activityViewerfor the sequencehttps://claude.ai/code/session_012L3AUuFDfGTspJMf9W7Sf2
Generated by Claude Code