Skip to content
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 - ISSUE #2727 - fix for back button redirect to submit on review page #2845

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions src/registrar/assets/js/get-gov.js
Original file line number Diff line number Diff line change
Expand Up @@ -2228,3 +2228,32 @@ const utcDateString = (dateString) => {
}
}
})();


/**
* An IIFE that redirects to the home page when a user clicks on the back button on the 'request/finished/' page
*/

(function() {
document.addEventListener("DOMContentLoaded", () => {
const currentPath = window.location.pathname;

if (currentPath === "/request/finished/") {

// Push a dummy state to create a history entry
history.pushState({ page: "dummy" }, "Dummy Page", "/request/review");
// Replace the current state with the correct page state
history.replaceState({ page: "finished" }, "Finished Page", "/request/finished/")

// Listen for back button click event
window.addEventListener("popstate", (event) => {
// Handle back navigation
if (!event.state || event.state.page !== "finished") {
// Redirect to home page
window.location.href = "/";
}
});
}
});
})();

Loading