fix: presentation material form reset - #1019
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthrough
ChangesEvent material form
Estimated code review effort: 4 (Complex) | ~45 minutes Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/components/forms/event-material-form.js`:
- Around line 56-59: Update the mediaUploadsOpts mapping in the event material
form to safely handle an undefined event.type during initial render and
handleChangeMUType. Use the existing event data when available and fall back to
an empty list before calling map.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: e7020f9e-94a8-4f9a-a171-d874adb218dc
📒 Files selected for processing (1)
src/components/forms/event-material-form.js
| if (!shallowEqual(prevProps.errors, this.props.errors)) { | ||
| state.errors = { ...this.props.errors }; | ||
| } | ||
| useEffect(() => { |
There was a problem hiding this comment.
@santipalenque This PR rewrites the component's entire state-reset mechanism (class componentDidUpdate/shallowEqual → useEffect([entity])/useEffect([errors])) to fix the "adding new material shows previous description" bug, but ships with no test exercising that reset path — event-material-form.js has never had its own test file, and edit-event-material-page.test.js fully mocks EventMaterialForm, so it can't catch a regression here.
Without a reproducing test, if this reset logic is touched again later, the exact bug this PR fixes (stale entity/description carrying over when switching from an existing material to "add new") can silently reappear with nothing in the suite to flag it.
Suggested fix: add src/components/forms/__tests__/event-material-form.test.js covering the reset case — render with a populated entity (non-empty description), then rerender with a fresh/default-shaped entity prop (as happens on navigating to "add new"), and assert the description/name fields no longer show the old value.
https://app.clickup.com/t/9014802374/86bb18pbh
Summary by CodeRabbit