Skip to content

Conversation

@rishabh8870
Copy link

Add beforeunload event listener to warn users when closing tab during active chat

Description

This PR implements a warning dialog when users attempt to close the browser tab while actively chatting (on the /founduser route). This prevents accidental data loss and provides a better user experience.

Changes Proposed

  • Added a beforeunload event listener in the App component
  • The listener checks if the user is on the /founduser route (active chat)
  • If in chat mode, it prevents the default unload and shows the browser's confirmation dialog
  • Properly cleans up the event listener on component unmount

How to Test

  1. Start a chat with another user (navigate to /founduser)
  2. Try to close the browser tab or navigate away
  3. A browser confirmation dialog should appear
  4. Click Cancel to stay in chat, or Leave to close

Fixes issue #452

Add event listener to prevent data loss on unload if in chat mode.
@vercel
Copy link

vercel bot commented Dec 16, 2025

@rishabh8870 is attempting to deploy a commit to the dunsin's projects Team on Vercel.

A member of the Team first needs to authorize it.

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Compliance Checks

Thank you for your Pull Request! We have run several checks on this pull request in order to make sure it's suitable for merging into this project. The results are listed in the following section.

Issue Reference In order to be considered for merging, the pull request description must refer to a specific issue number. This is described in our Contributing Guide. This check is looking for a phrase similar to: "Fixes #XYZ" or "Resolves #XYZ" where XYZ is the issue number that this PR is meant to address.

Conventional Commit PR Title

In order to be considered for merging, the pull request title must match the specification in conventional commits. You can edit the title in order for this check to pass.
Most often, our PR titles are something like one of these:

  • docs: correct typo in README
  • feat: implement dark mode"
  • fix: correct remove button behavior

Linting Errors

  • Found type "null", must be one of "feat","fix","docs","style","refactor","perf","test","build","ci","chore","revert"
  • No subject found

@Dun-sin
Copy link
Owner

Dun-sin commented Dec 18, 2025

Your pull request is rejected, reason 👉🏾is here👈🏾

Let me know if you think this is a misunderstanding, and we'll work on how you can properly contribute.

Thanks for trying, I hope you continue to do so properly.

@Dun-sin Dun-sin closed this Dec 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants