Keep a reopened template draft off the setup questions.

This commit is contained in:
adilallo committed 2026-11-09 17:42:04 -07:00
1 parent 6498d52541
commit c7f88e5515
3 files changed
+55 -3

No files matched your search

+16 -3
View File
@@ -25,6 +25,7 @@ import {
CREATE_FLOW_REVIEW_RETURN_QUERY_KEY,
getNextStep,
parseReviewReturnSearchParam,
templatePathSkippedCommunityRedirect,
shouldOfferCreateFlowSaveAndExit,
isDirectTemplateReviewEntry,
createFlowStepUsesSelectSplitScroll,
@@ -101,6 +102,7 @@ import {
EMPTY_SETUP_TRAITS,
hasTickedSetupTrait,
} from "../../../lib/create/setupTraits";
import { templatePathFromState } from "../../../lib/create/templatePath";
import { useAuthModal } from "../../contexts/AuthModalContext";
import { useMessages, useTranslation } from "../../contexts/MessagesContext";
import { PostLoginDraftTransfer } from "./PostLoginDraftTransfer";
@@ -424,7 +426,18 @@ function CreateFlowLayoutContent({
await runAuthenticatedExit(opts);
};
const templatePathRedirect = templatePathSkippedCommunityRedirect(
currentStep,
templatePathFromState(state)?.mode,
);
useEffect(() => {
if (!templatePathRedirect) return;
router.replace(createFlowStepPath(templatePathRedirect));
}, [router, templatePathRedirect]);
useEffect(() => {
if (templatePathRedirect) return;
if (
sessionResolved &&
sessionUser &&
@@ -432,7 +445,7 @@ function CreateFlowLayoutContent({
) {
router.replace(CREATE_ROUTES.review);
}
}, [sessionResolved, sessionUser, currentStep, router]);
}, [sessionResolved, sessionUser, currentStep, router, templatePathRedirect]);
useEffect(() => {
clearAttempted();
@@ -967,9 +980,9 @@ function CreateFlowLayoutContent({
<main
className={`flex min-h-0 min-w-0 flex-1 w-full max-w-full overflow-x-hidden ${CREATE_FLOW_SCROLL_REGION_CLASS} ${mainContentClass} ${mainResponsiveLayout}`}
>
{children}
{templatePathRedirect ? null : children}
</main>
{!isCompletedStep && (
{!isCompletedStep && !templatePathRedirect && (
<CreateFlowFooter
className="shrink-0"
contentMaxClass={getCreateFlowContentMaxClass({
+14
View File
@@ -96,6 +96,20 @@ function shouldSkipStep(
);
}
/**
* Where to send a template-path draft that reopened on a community setup
* step. Customize resumes at values; Use without changes resumes at final
* review. Deck steps stay put so final-review + Add can open one.
*/
export function templatePathSkippedCommunityRedirect(
currentStep: CreateFlowStep | null | undefined,
mode: CreateFlowNavigationOptions["templatePathMode"],
): CreateFlowStep | null {
if (!currentStep || !mode) return null;
if (!TEMPLATE_PATH_COMMUNITY_SKIP.has(currentStep)) return null;
return mode === "customize" ? "core-values" : "final-review";
}
/**
* Returns the next step in the flow, or null if current is last/invalid
*/
+25
View File
@@ -10,6 +10,7 @@ import {
parseCreateFlowScreenFromPathname,
resolveCreateFlowBackTarget,
shouldOfferCreateFlowSaveAndExit,
templatePathSkippedCommunityRedirect,
isDirectTemplateReviewEntry,
isCreateFlowTemplatesPickerPath,
createFlowStepUsesSelectSplitScroll,
@@ -113,6 +114,30 @@ describe("flowSteps", () => {
expect(getPreviousStep("final-review", opts)).toBeNull();
});
it("templatePathSkippedCommunityRedirect resumes setup steps and leaves decks", () => {
expect(
templatePathSkippedCommunityRedirect("setup-questions", "customize"),
).toBe("core-values");
expect(templatePathSkippedCommunityRedirect("review", "customize")).toBe(
"core-values",
);
expect(
templatePathSkippedCommunityRedirect(
"community-name",
"useWithoutChanges",
),
).toBe("final-review");
expect(
templatePathSkippedCommunityRedirect("core-values", "useWithoutChanges"),
).toBeNull();
expect(
templatePathSkippedCommunityRedirect("final-review", "customize"),
).toBeNull();
expect(
templatePathSkippedCommunityRedirect("setup-questions", undefined),
).toBeNull();
});
it("templatePathMode composes with skipCommunitySave", () => {
const opts = {
skipCommunitySave: true,