-
Notifications
You must be signed in to change notification settings - Fork 128
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bug: [Title] Extra Pop Up After creating new project #399 #407
Conversation
WalkthroughThe pull request introduces changes to two files: Changes
Assessment against linked issues
Poem
Finishing Touches
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
✅ Deploy Preview for circuitverse ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (2)
src/simulator/src/data/project.ts (2)
158-167
: Simplify the complex boolean condition.The nested boolean conditions are hard to read. Consider extracting the logic into meaningful variables.
- if ( - !verify && - (!projectSaved && checkToSave()) && - !(await confirmOption( - 'What you like to start a new project? Any unsaved changes will be lost.' - )) - ) + const hasUnsavedChanges = !projectSaved && checkToSave(); + const needsConfirmation = !verify && hasUnsavedChanges; + if (needsConfirmation && !(await confirmOption( + 'Would you like to start a new project? Any unsaved changes will be lost.' + )))Also, there's a typo in the confirmation message: "What you like" should be "Would you like".
173-174
: Consider using router navigation instead of location.assign.Using
window.location.assign
causes a full page reload. Consider using the Vue router for a smoother user experience.// Example using Vue Router router.push('/simulatorvue/')
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
src/components/Panels/ElementsPanel/ElementsPanel.vue
(3 hunks)src/simulator/src/data/project.ts
(2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (3)
- GitHub Check: Redirect rules - circuitverse
- GitHub Check: Header rules - circuitverse
- GitHub Check: Pages changed - circuitverse
🔇 Additional comments (3)
src/simulator/src/data/project.ts (2)
Line range hint
123-178
: Implementation successfully addresses the double popup issue.The changes effectively solve the problem by removing the default browser popup while maintaining the custom confirmation dialog for unsaved changes.
123-139
: 🛠️ Refactor suggestionRemove commented code instead of keeping it.
The commented-out
window.onbeforeunload
handler should be removed rather than left as comments. If needed, the code history can be referenced through version control.Verify data loss prevention.
With the removal of the
onbeforeunload
handler, ensure there are other mechanisms in place to prevent accidental data loss when users navigate away with unsaved changes.Run this script to check for other data preservation mechanisms:
✅ Verification successful
Removal of commented code is safe - other data preservation mechanisms are active
The codebase has multiple active data preservation mechanisms:
- User confirmations before destructive actions using
checkToSave()
- Project recovery functionality through
recoverProject()
- Explicit warnings for unsaved changes when starting new projects
You can safely remove the commented-out code as it was causing duplicate warnings.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Search for other data saving/recovery mechanisms rg -A 3 "localStorage.setItem.*recover" rg "unsaved.*changes"Length of output: 1619
Script:
#!/bin/bash # Check for active data preservation mechanisms ast-grep --pattern 'function checkToSave() { $$$ }' ast-grep --pattern 'function recoverProject() { $$$ }' rg -B 2 -A 5 "What you like to start a new project\? Any unsaved changes will be lost\."Length of output: 2099
src/components/Panels/ElementsPanel/ElementsPanel.vue (1)
128-131
: Consider moving UI enhancements to a separate PR.While the UI improvements are valuable, they are unrelated to the popup issue fix. Consider submitting these changes in a separate PR for better change tracking and review focus.
Fixes #399
Bug Fix Summary: Extra Pop-Up Issue
Before Fix:
window.onbeforeunload
).After Fix:
window.onbeforeunload
function.confirmOption
function to prompt user responses.Screen Recording
2025-01-15.22-31-37.mp4
Summary by CodeRabbit
User Interface
Project Management