Stop duplicating dates when duplicating questions#4502
Stop duplicating dates when duplicating questions#4502SylvainChevalier wants to merge 1 commit intomainfrom
Conversation
When duplicating a question (mode='create' with existing post), skip copying scheduling date fields (open_time, scheduled_close_time, scheduled_resolve_time, cp_reveal_time, published_at) so they start empty. Bounds (range_min, range_max) and zero_point for date range questions are still duplicated as before. Fixes #4456 Co-authored-by: Sylvain <SylvainChevalier@users.noreply.github.com>
📝 WalkthroughWalkthroughChanges to form component initialization logic introduce an Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
📝 Coding Plan
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
🚀 Preview EnvironmentYour preview environment is ready!
Details
ℹ️ Preview Environment InfoIsolation:
Limitations:
Cleanup:
|
|
lgtm. |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
front_end/src/app/(main)/questions/components/question_form.tsx (1)
974-980:⚠️ Potential issue | 🟡 MinorMissing
isDuplicatecheck forpublished_atDateInput.Per the PR objective,
published_atshould also be cleared during duplication. While the form'sdefaultValues(line 474) sets it toundefined, thisDateInputcomponent'sdefaultValueprop is inconsistent with the other date fields (lines 877, 890, 906, 919) that all use theisDuplicateconditional.🔧 Proposed fix for consistency
<DateInput control={form.control as unknown as Control<FieldValues>} name="published_at" - defaultValue={post?.published_at} + defaultValue={isDuplicate ? undefined : post?.published_at} errors={form.formState.errors.published_at} className="w-full rounded border border-gray-500 px-3 py-2 text-base dark:border-gray-500-dark dark:bg-blue-50-dark" />🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@front_end/src/app/`(main)/questions/components/question_form.tsx around lines 974 - 980, The DateInput for published_at is missing the isDuplicate check, causing duplication to retain the original date; update the DateInput (name="published_at", component DateInput using form.control and form.formState.errors) to set its defaultValue the same way as the other date fields—i.e. use the isDuplicate conditional so defaultValue is undefined when isDuplicate is true (instead of always using post?.published_at) to match the form's defaultValues behavior.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Outside diff comments:
In `@front_end/src/app/`(main)/questions/components/question_form.tsx:
- Around line 974-980: The DateInput for published_at is missing the isDuplicate
check, causing duplication to retain the original date; update the DateInput
(name="published_at", component DateInput using form.control and
form.formState.errors) to set its defaultValue the same way as the other date
fields—i.e. use the isDuplicate conditional so defaultValue is undefined when
isDuplicate is true (instead of always using post?.published_at) to match the
form's defaultValues behavior.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 2d6a2a73-bdf8-4722-8219-588d0992b52d
📒 Files selected for processing (2)
front_end/src/app/(main)/questions/components/group_form.tsxfront_end/src/app/(main)/questions/components/question_form.tsx
|
oops I put the wrong PR up for review. |
Fixes #4456
When duplicating a question, skip copying scheduling date fields (open_time, scheduled_close_time, scheduled_resolve_time, cp_reveal_time, published_at) so they start empty. Bounds and zero point for date range questions are still duplicated.
Generated with Claude Code
Summary by CodeRabbit
Release Notes