mirror of
https://github.com/harvard-edge/cs249r_book.git
synced 2026-07-18 00:44:29 -05:00
[PR #1819] [MERGED] fix(staffml): reset QuestionVisual failed state on visual.path change #32149
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/harvard-edge/cs249r_book/pull/1819
Author: @farhan523
Created: 5/29/2026
Status: ✅ Merged
Merged: 6/2/2026
Merged by: @profvjreddi
Base:
dev← Head:fix/question-visual-reset-on-prop-change📝 Commits (1)
c19d9fafix(staffml): reset QuestionVisual failed state on visual.path change📊 Changes
3 files changed (+58 additions, -0 deletions)
View changed files
➕
interviews/staffml/src/__tests__/question-visual.test.tsx(+45 -0)📝
interviews/staffml/src/__tests__/setup.ts(+8 -0)📝
interviews/staffml/src/components/QuestionVisual.tsx(+5 -0)📄 Description
Summary
QuestionVisualin its error state across navigation.failed=trueshort-circuited before the next question's<img>could mount, so itsonErrorcould never reset things. Users saw "Diagram failed to load" on questions whose images were fine.useState+ compare pattern asvault/TopicDetail.tsx, which React's docs recommend for resetting state when a prop changes.ResizeObserverstub in the vitestsetup.tssoreact-medium-image-zoommounts cleanly under jsdom — without it the new test crashes.Test plan
npx vitest run→ 39/39 passing (was 37/37)npx tsc --noEmit→ clean/practice, block a diagram URL in DevTools → red error shows, navigate to next question → new diagram loads (instead of staying in error state)🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.