forked from openfrontio/OpenFrontIO
-
Notifications
You must be signed in to change notification settings - Fork 0
Fix duplicate window close confirmation dialogs when leaving game intentionally #4
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
Draft
Copilot
wants to merge
15
commits into
main
Choose a base branch
from
copilot/fix-window-close-confirmation
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Co-authored-by: Foorack <5008081+Foorack@users.noreply.github.com>
Co-authored-by: Foorack <5008081+Foorack@users.noreply.github.com>
Co-authored-by: Foorack <5008081+Foorack@users.noreply.github.com>
Refine comment to clarify when the confirmation dialog appears.
Co-authored-by: Foorack <5008081+Foorack@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
- Changed joinLobby to return a LobbyControl object with cleanup and shouldPreventUnload methods - Moved currentGameRunner from module-level to local closure within joinLobby - Updated Main.ts to use the new LobbyControl API instead of separate gameStop and shouldPreventUnload functions - All tests pass and build is successful Co-authored-by: Foorack <5008081+Foorack@users.noreply.github.com>
Instead of LobbyControl interface, joinLobby now returns a function that: - Checks if it should prevent closing (player alive in game) - Returns false if close was prevented, true if successful - Eliminates the need for separate cleanup and shouldPreventUnload methods This is a simpler approach as suggested in the code review. Co-authored-by: Foorack <5008081+Foorack@users.noreply.github.com>
- Renamed property from leaveLobby to gameStop to minimize diff from original - Removed verbose comments to keep only essential ones - Maintains same functionality with cleaner code Co-authored-by: Foorack <5008081+Foorack@users.noreply.github.com>
Co-authored-by: Foorack <5008081+Foorack@users.noreply.github.com>
…-function Add JSDoc documentation to shouldPreventWindowClose method
Co-authored-by: Foorack <5008081+Foorack@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix window close confirmation dialog behavior
Fix duplicate window close confirmation dialogs when leaving game intentionally
Oct 8, 2025
Copilot finished work on behalf of
Foorack
October 8, 2025 21:16
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
Users were experiencing duplicate confirmation dialogs when leaving the game using the Leave button (❌) in the top-right corner:
beforeunloadconfirmationThis created a poor user experience with redundant prompts. Additionally, the
beforeunloadconfirmation was incorrectly showing when users intentionally left the game, rather than only when closing the browser window/tab.Solution
This PR introduces a minimal flag-based solution to track intentional navigation. When users click any exit/leave button in the game and confirm their intent, the flag is set to prevent the
beforeunloadhandler from showing a second confirmation.Changes Made
isIntentionalNavigationflag and exportedsetIntentionalNavigation()function for use by UI componentssetIntentionalNavigation()before redirecting when user clicks LeavesetIntentionalNavigation()before redirecting when user clicks ExitsetIntentionalNavigation()before redirecting when user clicks ExitsetIntentionalNavigation()before redirecting when user clicks ExitThe
beforeunloadevent handler now checks the flag and skips showing the confirmation if navigation is intentional.Behavior After Fix
beforeunloadconfirmation dialog ✅Testing
This fix ensures the window close confirmation only appears when users are actually closing the browser window/tab, not when they're intentionally leaving the game through UI controls.
Original prompt
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.