Skip to content

fix: presentation material form reset#1019

Open
santipalenque wants to merge 1 commit into
masterfrom
fix/presentation-material-form-reset
Open

fix: presentation material form reset#1019
santipalenque wants to merge 1 commit into
masterfrom
fix/presentation-material-form-reset

Conversation

@santipalenque

@santipalenque santipalenque commented Jul 22, 2026

Copy link
Copy Markdown

https://app.clickup.com/t/9014802374/86bb18pbh

Summary by CodeRabbit

  • Bug Fixes
    • Improved event material form behavior when existing data or validation errors change.
    • Fixed file and media upload handling, including clearing removed files and updating uploaded file details.
    • Improved validation error display and automatic scrolling to errors.
    • Refined conditional fields and input states based on the selected material type.

@coderabbitai

coderabbitai Bot commented Jul 22, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

EventMaterialForm was converted to a functional React component using hooks. Form state, error synchronization, field handlers, submission, conditional rendering, and media upload behavior were updated to use hook-managed state.

Changes

Event material form

Layer / File(s) Summary
Hook state and prop synchronization
src/components/forms/event-material-form.js
React hooks replace class state wiring, derive media configuration and input state, and synchronize entity and validation props with effects.
Form behavior and media rendering
src/components/forms/event-material-form.js
Handlers update fields and upload metadata, remove files, submit entityState, and render conditional inputs with updated media upload and error handling.

Estimated code review effort: 4 (Complex) | ~45 minutes

Suggested reviewers: smarcet

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title is concise and accurately reflects the main fix: resetting the presentation material form state.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/presentation-material-form-reset

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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

📥 Commits

Reviewing files that changed from the base of the PR and between 53b15bf and 6520aa5.

📒 Files selected for processing (1)
  • src/components/forms/event-material-form.js

Comment on lines +56 to +59
const mediaUploadsOpts = event.type.allowed_media_upload_types.map((mu) => ({
label: mu.name,
value: mu.id
}));

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Find EventMaterialForm mount sites and how `event` is passed
rg -nP --type=js -C4 '<EventMaterialForm\b' 
# Locate the removed defaults referenced by the commit
rg -nP --type=js -C3 '\b(defaultProps|allowed_media_upload_types)\b' src

Repository: fntechgit/summit-admin

Length of output: 160


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Map the target file and nearby uses
git ls-files | rg '^src/components/forms/event-material-form\.js$|^src/components/forms/|^src/'

printf '\n--- outline ---\n'
ast-grep outline src/components/forms/event-material-form.js --view expanded || true

printf '\n--- file excerpt ---\n'
wc -l src/components/forms/event-material-form.js
cat -n src/components/forms/event-material-form.js | sed -n '1,220p'

printf '\n--- search for mount sites / props passing ---\n'
rg -n --glob '!**/node_modules/**' -C 3 'EventMaterialForm|event-material-form' src

Repository: fntechgit/summit-admin

Length of output: 50378


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Find the component definition and any immediate guards around event usage
rg -n --glob '!**/node_modules/**' -C 4 'allowed_media_upload_types|handleChangeMUType|event\.type|event\?' src/components/forms/event-material-form.js src

Repository: fntechgit/summit-admin

Length of output: 50378


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Locate the component file and inspect the relevant lines plus surrounding props/defaults
fd -a 'event-material-form.js' src || true
printf '\n--- nearby references ---\n'
rg -n --glob '!**/node_modules/**' -C 4 'event\.type\.allowed_media_upload_types|handleChangeMUType|defaultProps|propTypes|EventMaterialForm' src/components src

Repository: fntechgit/summit-admin

Length of output: 50379


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Read the component and related surrounding context directly
file=src/components/forms/event-material-form.js
wc -l "$file"
printf '\n--- top ---\n'
cat -n "$file" | sed -n '1,180p'

printf '\n--- references to event in this file ---\n'
rg -n --no-heading 'event|allowed_media_upload_types|defaultProps|propTypes' "$file"

Repository: fntechgit/summit-admin

Length of output: 8506


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Find exact imports/usages of EventMaterialForm and inspect the immediate parent page
rg -n --glob '!**/node_modules/**' 'EventMaterialForm' src/components src/pages

printf '\n--- parent page excerpt ---\n'
file=src/pages/events/edit-event-material-page.js
wc -l "$file"
cat -n "$file" | sed -n '1,240p'

printf '\n--- component metadata excerpt ---\n'
file=src/components/forms/event-material-form.js
rg -n --no-heading 'propTypes|defaultProps|event:' "$file"

Repository: fntechgit/summit-admin

Length of output: 5178


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Inspect the event material form's prop handling and any guards in the call chain
file=src/components/forms/event-material-form.js
ast-grep outline "$file" --view expanded || true

printf '\n--- exact prop usage ---\n'
rg -n --no-heading -C 3 'const EventMaterialForm|useEffect|event\.type\.allowed_media_upload_types|onSubmit|event\b' "$file"

Repository: fntechgit/summit-admin

Length of output: 1875


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Check the event state shape and how event material loads the event
printf '%s\n' '--- currentSummitEventState reducer ---'
file=src/reducers/events/summit-event-reducer.js
wc -l "$file"
cat -n "$file" | sed -n '1,220p'

printf '\n%s\n' '--- event material action path ---'
file=src/actions/event-material-actions.js
wc -l "$file"
cat -n "$file" | sed -n '1,240p'

printf '\n%s\n' '--- search for currentSummitEventState entity initialization/usages ---'
rg -n --glob '!**/node_modules/**' -C 3 'currentSummitEventState|summit-event-reducer|entity:' src/reducers src/actions src/pages/events

Repository: fntechgit/summit-admin

Length of output: 50379


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Find whether event.type is normalized before this page mounts
rg -n --glob '!**/node_modules/**' -C 3 'normalizeEvent\(|getEventMaterial\(|saveEventMaterial\(|saveEventMaterialWithFile\(' src/actions src/reducers src/pages/events

Repository: fntechgit/summit-admin

Length of output: 4832


🏁 Script executed:

#!/bin/bash
set -euo pipefail

file=src/reducers/events/summit-event-reducer.js
wc -l "$file"
printf '\n--- defaults and entity updates ---\n'
rg -n --no-heading -C 4 'DEFAULT_ENTITY|DEFAULT_STATE|RECEIVE_|RESET_|UPDATE_|type_id|allowed_media_upload_types|type:' "$file"
printf '\n--- first 140 lines ---\n'
cat -n "$file" | sed -n '1,140p'

Repository: fntechgit/summit-admin

Length of output: 9644


🏁 Script executed:

#!/bin/bash
set -euo pipefail

file=src/actions/event-actions.js
printf '%s\n' '--- normalizeEvent definition ---'
rg -n --no-heading -C 6 'function normalizeEvent|const normalizeEvent|export const normalizeEvent' "$file"
printf '\n%s\n' '--- around normalizeEvent use in save/load paths ---\n'
rg -n --no-heading -C 4 'normalizeEvent\(' "$file"

Repository: fntechgit/summit-admin

Length of output: 2143


Guard event.type before mapping media upload types. event starts as the reducer’s default entity, so event.type is undefined on the first render and in handleChangeMUType. Use a fallback like event?.type?.allowed_media_upload_types ?? [].

🤖 Prompt for 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.

In `@src/components/forms/event-material-form.js` around lines 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.

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.

1 participant