Skip to content

feat: add unsaved changes warning when leaving CreatePage with filled…#396

Merged
Aamod-Dev merged 3 commits into
niharika-mente:mainfrom
arpita-1111:feat/unsaved-changes-warning
Jun 21, 2026
Merged

feat: add unsaved changes warning when leaving CreatePage with filled…#396
Aamod-Dev merged 3 commits into
niharika-mente:mainfrom
arpita-1111:feat/unsaved-changes-warning

Conversation

@arpita-1111

Copy link
Copy Markdown
Contributor

Closes #335

Problem

If a user fills in form fields and navigates away (clicks a link,
back button, or closes tab), all entered data is lost with no
confirmation dialog.

Solution

  • Added isDirty state to track if form has unsaved changes
  • Added beforeunload event listener to warn on tab close/refresh
  • Added click interceptor to warn on React Router link navigation
  • Warning is dismissed automatically after successful form submission

Testing

  1. Go to Create Product page
  2. Fill in any field
  3. Click any nav link → confirm dialog appears
  4. Press Ctrl+R (refresh) → browser warning appears
  5. Submit product successfully → no warning appears

@vercel

vercel Bot commented Jun 21, 2026

Copy link
Copy Markdown

Someone is attempting to deploy a commit to the niharika-mente's projects Team on Vercel.

A member of the Team first needs to authorize it.

@arpita-1111 arpita-1111 force-pushed the feat/unsaved-changes-warning branch from 01f4680 to e378e1a Compare June 21, 2026 18:11
Aamod-Dev
Aamod-Dev previously approved these changes Jun 21, 2026

@Aamod-Dev Aamod-Dev left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Looks good, approved!

@Aamod-Dev Aamod-Dev left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Looks good, approved!

@Aamod-Dev Aamod-Dev merged commit a2ba20c into niharika-mente:main Jun 21, 2026
1 of 4 checks passed
@arpita-1111 arpita-1111 deleted the feat/unsaved-changes-warning branch June 21, 2026 18:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature: Add unsaved changes warning when leaving CreatePage with filled form

2 participants