Skip to content

Fully autonomous AI Agents system capable of performing complex penetration testing tasks

fix(templates): skip the unsaved-guard blocker on the post-create navigation

Sergey Kozyrenkof68964f52ed9
diff --git a/frontend/src/pages/templates/template.tsx b/frontend/src/pages/templates/template.tsx
index 75f28775..c5a6e759 100644
--- a/frontend/src/pages/templates/template.tsx
+++ b/frontend/src/pages/templates/template.tsx
@@ -365,16 +365,6 @@ function Template() {
[isNew, templateId, createTemplate, updateTemplate, reset],
);
- const handleSubmit = async (values: FormValues) => {
- if (isSaving) {
- return;
- }
-
- if ((await performSave(values)) && isNew) {
- navigate(routes.templates);
- }
- };
-
const handleSaveFromGuard = useCallback(async (): Promise<boolean> => {
if (isSaving || !isValid) {
return false;
@@ -391,6 +381,19 @@ function Template() {
onSave: handleSaveFromGuard,
});
+ const handleSubmit = async (values: FormValues) => {
+ if (isSaving) {
+ return;
+ }
+
+ if ((await performSave(values)) && isNew) {
+ // A fresh template stays dirty until we leave; skip the guard's blocker so this post-save
+ // navigation doesn't trap the user in the unsaved-changes dialog.
+ guard.skipNextBlock();
+ navigate(routes.templates);
+ }
+ };
+
const handleApplyPreset = useCallback(
(preset: { text: string; title: string }) => {
const current = getValues();