Skip to content

feat: adds navigation blocker hook#4608

Draft
fpigeonjr wants to merge 11 commits intomainfrom
feature/shared-nav-blocker
Draft

feat: adds navigation blocker hook#4608
fpigeonjr wants to merge 11 commits intomainfrom
feature/shared-nav-blocker

Conversation

@fpigeonjr
Copy link
Contributor

What changed

Described what changes in this PR, at a high level

Issue

Add link to issue here

How to test

Write out steps for how someone could test this PR against the acceptance criteria

Screenshots

If relevant, e.g. for a front-end feature

Definition of Done Checklist

  • OESA: Code refactored for clarity
  • OESA: Dependency rules followed
  • Automated unit tests updated and passed
  • Automated integration tests updated and passed
  • Automated quality tests updated and passed
  • Automated load tests updated and passed
  • Automated a11y tests updated and passed
  • Automated security tests updated and passed
  • 90%+ Code coverage achieved
  • Form validations updated

Links

If relevant, e.g. for a link to a piece of markdown documentation

@fpigeonjr fpigeonjr self-assigned this Oct 30, 2025
@fpigeonjr fpigeonjr changed the title feat: adds navigation blocker context feat: adds navigation blocker hook Nov 4, 2025
@fpigeonjr fpigeonjr requested a review from Copilot November 4, 2025 17:16
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR introduces a new simple navigation blocker hook (useSimpleNavigationBlocker) and refactors the budget lines and services components to use it for managing unsaved changes during navigation. The changes consolidate navigation blocking logic to prevent multiple conflicting blockers and improve the user experience when navigating away from pages with unsaved changes.

Key Changes

  • Added useSimpleNavigationBlocker hook to handle navigation blocking following React Router best practices
  • Refactored CreateBLIsAndSCs to use the new navigation blocker and track unsaved changes from both budget lines and services components
  • Simplified modal handling logic by removing confirmation dialogs from delete and cancel operations

Reviewed Changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
useSimpleNavigationBlocker.js New hook implementing navigation blocking with modal management
useNavigationBlocker.test.js Test suite for navigation blocker functionality (tests non-existent hooks)
SaveChangesAndExitModal.jsx Updated dependency array and simplified button click handler
ServicesComponents.jsx Added callback prop for tracking unsaved changes state
ServicesComponents.hooks.js Added unsaved changes tracking and save handler, removed commented blocker code
CreateBLIsAndSCs.jsx Updated modal rendering logic and props passing
CreateBLIsAndSCs.hooks.js Major refactor using new navigation blocker, simplified delete/cancel flows

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +54 to +61
if (showSuccessAlert) {
setAlert({
type: "success",
heading: "Services Components Saved",
message: "Your changes have been successfully saved.",
isCloseable: true
});
}
Copy link

Copilot AI Nov 4, 2025

Choose a reason for hiding this comment

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

The handleSave function is a no-op that only resets state without actually saving anything, yet it shows success alerts claiming changes were saved. This is misleading and could confuse users. Consider either implementing actual save logic or removing the success alert until the batching implementation is added.

Suggested change
if (showSuccessAlert) {
setAlert({
type: "success",
heading: "Services Components Saved",
message: "Your changes have been successfully saved.",
isCloseable: true
});
}
// Success alert removed: no actual save is performed here.

Copilot uses AI. Check for mistakes.
scrollToTop();
}
},
[tempBudgetLines, addBudgetLineItem, isSuperUser, setIsEditMode, setHasUnsavedChanges, setAlert]
Copy link

Copilot AI Nov 4, 2025

Choose a reason for hiding this comment

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

The dependency array for handleSave is incomplete. It's missing several dependencies that are used in the callback: handleFinancialSnapshotChanges, handleRegularUpdates, handleDeletions, suite, budgetFormSuite, datePickerSuite, resetForm, showSuccessMessage, and setServicesComponentsHasUnsavedChanges. This could lead to stale closures and bugs.

Suggested change
[tempBudgetLines, addBudgetLineItem, isSuperUser, setIsEditMode, setHasUnsavedChanges, setAlert]
[
tempBudgetLines,
addBudgetLineItem,
isSuperUser,
setIsEditMode,
setHasUnsavedChanges,
setAlert,
handleFinancialSnapshotChanges,
handleRegularUpdates,
handleDeletions,
suite,
budgetFormSuite,
datePickerSuite,
resetForm,
showSuccessMessage,
setServicesComponentsHasUnsavedChanges
]

Copilot uses AI. Check for mistakes.
@fpigeonjr fpigeonjr mentioned this pull request Nov 5, 2025
9 tasks
Base automatically changed from OPS-4465/Improve-save-changes-edits to main November 12, 2025 21:28
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.

1 participant