fix: replace window.confirm with ConfirmDialog component (#997)#1410
Conversation
|
Hi @Xenon010101, thanks for contributing to InternHack! 🎉 I have automatically:
Our workflows will now analyze your changes to classify:
Tip Ensure your PR description references the issue it resolves (e.g. Happy coding! 🚀 |
📝 WalkthroughWalkthroughFirstPRRoadmapPage replaces the native browser ChangesConfirmDialog-driven reset flow
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Possibly related PRs
Suggested labels
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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 |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
client/src/module/student/opensource/FirstPRRoadmapPage.tsx (1)
163-175: ⚡ Quick winConsider moving ConfirmDialog outside the AnimatePresence block.
The
ConfirmDialogis currently nested inside theAnimatePresenceblock (lines 138–180) that unmounts whenallDonebecomesfalse. When the user confirms the reset, bothsetCompleted(new Set())andsetShowResetConfirm(false)execute together, causing the parent banner and dialog to unmount simultaneously.While this doesn't cause functional issues, best practice is to render dialogs at the page level (outside conditional/animated blocks) to keep their lifecycle independent of the content they're confirming.
♻️ Recommended placement
Move the
ConfirmDialogoutside theAnimatePresenceblock to the page level, for example right before the closing</div>at line 275:</div> + + <ConfirmDialog + open={showResetConfirm} + title="Reset all steps?" + description="This will remove your progress and reset all completed steps." + confirmLabel="Reset" + cancelLabel="Cancel" + onConfirm={() => { + setCompleted(new Set()); + try { localStorage.removeItem(STORAGE_KEY); } catch { /**/ } + setShowResetConfirm(false); + }} + onCancel={() => setShowResetConfirm(false)} + /> </div> ); }And remove it from inside the completion banner:
<button onClick={() => setShowResetConfirm(true)} className="text-sm text-lime-700 dark:text-lime-400 border border-lime-400 px-3 py-0.5 rounded-lg font-medium" > Start over </button> - <ConfirmDialog - open={showResetConfirm} - title="Reset all steps?" - description="This will remove your progress and reset all completed steps." - confirmLabel="Reset" - cancelLabel="Cancel" - onConfirm={() => { - setCompleted(new Set()); - try { localStorage.removeItem(STORAGE_KEY); } catch { /**/ } - setShowResetConfirm(false); - }} - onCancel={() => setShowResetConfirm(false)} - /> </div>🤖 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 `@client/src/module/student/opensource/FirstPRRoadmapPage.tsx` around lines 163 - 175, The ConfirmDialog is rendered inside the AnimatePresence block so it unmounts together with the banner; move the ConfirmDialog JSX out of the AnimatePresence block to the page-level container (render it alongside the main page <div> rather than inside the banner), keeping the same props and handlers (open={showResetConfirm}, onConfirm that calls setCompleted(new Set()), localStorage.removeItem(STORAGE_KEY) and setShowResetConfirm(false), and onCancel={() => setShowResetConfirm(false)}); remove the in-banner instance so the dialog's lifecycle is independent of allDone toggles and banner unmounting.
🤖 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.
Nitpick comments:
In `@client/src/module/student/opensource/FirstPRRoadmapPage.tsx`:
- Around line 163-175: The ConfirmDialog is rendered inside the AnimatePresence
block so it unmounts together with the banner; move the ConfirmDialog JSX out of
the AnimatePresence block to the page-level container (render it alongside the
main page <div> rather than inside the banner), keeping the same props and
handlers (open={showResetConfirm}, onConfirm that calls setCompleted(new Set()),
localStorage.removeItem(STORAGE_KEY) and setShowResetConfirm(false), and
onCancel={() => setShowResetConfirm(false)}); remove the in-banner instance so
the dialog's lifecycle is independent of allDone toggles and banner unmounting.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 81f138d6-916e-4f60-9b28-c6b5194b619e
📒 Files selected for processing (1)
client/src/module/student/opensource/FirstPRRoadmapPage.tsx
Code Review — PR #1410: Replace window.confirm with ConfirmDialogHi @Xenon010101, the ConfirmDialog enhancements (Escape key, loading state, confirmVariant, children) are well implemented. One coordination issue to flag. 🟡 Merge conflict: PRs #1405, #1406, #1409, and this PR all apply identical changes to
|
e6dc9e3
into
Sachinchaurasiya360:main
…side first PR progress) Merges PR 939 (server-side tracking + optimistic updates) with main (Sachinchaurasiya360#1410 ConfirmDialog, Sachinchaurasiya360#1411 toast, step status badges). Key integrations: added ConfirmDialog for reset flow, inProgress-aware step circle/badge, smarter Est. Time display, and trimmedSearch fix in opensource.service.ts.
Description\nReplaces `window.confirm` with the existing `ConfirmDialog` component for a consistent design experience when resetting the roadmap.\n\n## Changes\n- Added `showResetConfirm` state to control dialog visibility\n- Imported `ConfirmDialog` component\n- Removed native `window.confirm` call\n\nCloses #997
Summary by CodeRabbit