Warn users before leaving playground with unsaved changes#456
Warn users before leaving playground with unsaved changes#456shubhamjrd4559-sudo wants to merge 1 commit into
Conversation
Qodo reviews are paused for this user.Troubleshooting steps vary by plan Learn more → On a Teams plan? Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center? |
👋 Thanks for opening a PR, @shubhamjrd4559-sudo!Your PR has entered the 🚦 PR Review Pipeline.
What happens next
A pipeline status comment will appear below and update automatically as your PR progresses. While you wait
This comment is posted only once. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (4)
🚧 Files skipped from review as they are similar to previous changes (1)
WalkthroughAdds a client-side hook that blocks browser unload and intercepts in-page link clicks when editors have unsaved changes; the hook is used on the playground page and its confirmNavigation callback is passed to the header to guard the “Back to Dashboard” action. ChangesUnsaved Changes Protection
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related issues
Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 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.
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 `@modules/playground/components/playground-header.tsx`:
- Around line 66-69: The current onClick handler calls confirmNavigation() and
then window.location.href = '/dashboard', which causes the beforeunload handler
from useUnsavedChangesWarning to trigger the native browser dialog and produce a
double prompt; fix this by importing Next's useRouter, call const router =
useRouter() inside the component, and replace window.location.href =
'/dashboard' with router.push('/dashboard') (or router.replace('/dashboard') if
you prefer replacing history) so navigation uses the Next router and avoids the
full unload/native prompt while still honoring confirmNavigation().
🪄 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: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 0deda88f-c7c3-4e17-b093-dfa46aadcb6e
📒 Files selected for processing (4)
app/playground/[id]/page.tsxmodules/playground/components/playground-header.tsxmodules/playground/hooks/useUnsavedChangesWarning.test.tsmodules/playground/hooks/useUnsavedChangesWarning.ts
2e6504e to
00927bc
Compare
|
Hi @piyushdotcomm, Just a friendly follow-up on PR #456. Whenever you have time, could you please review the PR and approve the pending workflows if everything looks good? Thank you for your time. |
Summary
Why
Closes #427.
Users can currently leave the Playground with unsaved edits and lose their work without any warning. This change reuses the existing
hasUnsavedChangesstate from open Playground files to display warnings only when there is actual unsaved editor content.Validation
npm.cmd run lintnpm.cmd testnpm.cmd run buildMaintainer Notes
This PR is submitted for review and merge into
main. I do not intend to merge it directly; please review and merge if it aligns with the project's standards and requirements.Summary by CodeRabbit
New Features
Tests