Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@Pallava-Joshi
Copy link
Contributor

@Pallava-Joshi Pallava-Joshi commented Nov 14, 2025

What does this PR do?

Fixes #25155

Screen.Recording.2025-11-14.at.2.58.03.PM.mov

Mandatory Tasks (DO NOT REMOVE)

  • I have self-reviewed the code (A decent size PR without self-review might be rejected).
  • I have updated the developer docs in /docs if this PR makes changes that would require a documentation change. If N/A, write N/A here and check the checkbox.
  • I confirm automated tests are in place that prove my fix is effective or that my feature works.

How should this be tested?

  • Create a new routing form
  • Add a new field
  • Without saving go to the "Routing Form" tab
  • Modal shows, and changes are preserved

Summary by cubic

Adds a save-confirmation modal when leaving the Routing Form editor for Route Builder, so unsaved changes are preserved instead of discarded.

  • New Features
    • Show a prompt to save when navigating away if the form is dirty or the field structure changed.
    • Detect structural changes by comparing field IDs and lengths, not only formState.isDirty.
    • Mark the form as dirty after add/remove/reorder actions to ensure the modal appears.

Written for commit d2a8956. Summary will update automatically on new commits.

@vercel
Copy link

vercel bot commented Nov 14, 2025

@Pallava-Joshi is attempting to deploy a commit to the cal Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions github-actions bot added community Created by Linear-GitHub Sync Medium priority Created by Linear-GitHub Sync 🐛 bug Something isn't working labels Nov 14, 2025
@github-actions
Copy link
Contributor

github-actions bot commented Nov 14, 2025

Hey there and thank you for opening this pull request! 👋🏼

We require pull request titles to follow the Conventional Commits specification and it looks like your proposed title needs to be adjusted.

Details:

No release type found in pull request title "implemented saving modal instead of discarding". Add a prefix to indicate what kind of release this pull request corresponds to. For reference, see https://www.conventionalcommits.org/

Available types:
 - feat: A new feature
 - fix: A bug fix
 - docs: Documentation only changes
 - style: Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc)
 - refactor: A code change that neither fixes a bug nor adds a feature
 - perf: A code change that improves performance
 - test: Adding missing tests or correcting existing tests
 - build: Changes that affect the build system or external dependencies (example scopes: gulp, broccoli, npm)
 - ci: Changes to our CI configuration files and scripts (example scopes: Travis, Circle, BrowserStack, SauceLabs)
 - chore: Other changes that don't modify src or test files
 - revert: Reverts a previous commit

@keithwillcode keithwillcode added the community-interns The team responsible for reviewing, testing and shipping low/medium community PRs label Nov 14, 2025
@Pallava-Joshi Pallava-Joshi changed the title implemented saving modal instead of discarding fix: implemented saving modal instead of discarding Nov 14, 2025
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

No issues found across 2 files

Comment on lines +43 to +50
const hasStructuralFieldChanges = () => {
const saved = form.fields ?? [];
const current = formContext.getValues("fields") ?? [];
if (saved.length !== current.length) return true;
for (let i = 0; i < saved.length; i++) {
if (saved[i]?.id !== current[i]?.id) return true;
}
return false;
Copy link
Contributor

Choose a reason for hiding this comment

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

what does structural field change mean?

return false;
};

const hasUnsaved = formContext.formState.isDirty || hasStructuralFieldChanges();
Copy link
Contributor

Choose a reason for hiding this comment

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

If possible we should try to just use formContext.formState.isDirty here. We also using isDirty pattern everywhere in our codebase. If something in form has been changed then isDirty must be true.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🐛 bug Something isn't working community Created by Linear-GitHub Sync community-interns The team responsible for reviewing, testing and shipping low/medium community PRs Medium priority Created by Linear-GitHub Sync size/M

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fix "Leave without saving" modal (Routing Forms)

3 participants