Run Use without changes through name, description, and photo so final review never holds an editable field #121

Merged
an.di merged 2 commits from adilallo/fix/CR-464-use-without-changes-name-first into main 2026-11-25 05:03:53 +00:00
6 changed files with 58 additions and 17 deletions
Showing only changes of commit 5dc936834c - Show all commits

No files matched your search

+6 -12
View File
@@ -866,24 +866,18 @@ function CreateFlowLayoutContent({
valuesCount={customizeDialog?.valuesCount ?? 0}
cardsCount={customizeDialog?.cardsCount ?? 0}
initialTitle={
fromCreateWizard && state.templateReviewEntryFromCreateFlow === true
? typeof state.title === "string"
? state.title
: ""
fromCreateWizard && typeof state.title === "string"
? state.title
: ""
}
initialDescription={
fromCreateWizard && state.templateReviewEntryFromCreateFlow === true
? typeof state.communityContext === "string"
? state.communityContext
: ""
fromCreateWizard && typeof state.communityContext === "string"
? state.communityContext
: ""
}
initialLocation={
fromCreateWizard && state.templateReviewEntryFromCreateFlow === true
? typeof state.communityLocation === "string"
? state.communityLocation
: ""
fromCreateWizard && typeof state.communityLocation === "string"
? state.communityLocation
: ""
}
onClose={closeCustomizeDialog}
@@ -145,8 +145,7 @@ export function useTemplateReviewActions({
pathname?.includes("/create/review-template/"),
);
const keepInFlowIdentity =
fromCreateWizard && state.templateReviewEntryFromCreateFlow === true;
const keepInFlowIdentity = fromCreateWizard;
const confirmReplaceDraft = useCallback(async (): Promise<boolean> => {
if (!requestConfirm) return true;
@@ -253,6 +252,7 @@ export function useTemplateReviewActions({
title: state.title,
communityContext: state.communityContext,
communityLocation: state.communityLocation,
communityAvatarUrl: state.communityAvatarUrl,
}
: undefined,
}),
@@ -264,6 +264,7 @@ export function useTemplateReviewActions({
markCreateFlowInteraction,
replaceState,
router,
state.communityAvatarUrl,
state.communityContext,
state.communityLocation,
signedIn,
+1 -1
View File
@@ -91,7 +91,7 @@ From that page, **Customize** opens a dialog for name, optional logo, descriptio
- **Use without changes (direct)** — home Popular templates, `/templates` without `fromFlow`, or a pasted review-template URL. Identity is collected on the name, description, and photo screens. Back from name returns to template review.
- **Use without changes (in-flow)** — `/create/review` → `/create/templates` → template. Community identity is already collected and pre-fills those three screens. Back from name still returns to template review.
**Direct entry vs in-flow template pick.** The same `/create/review-template/[slug]` URL is reached from two different origins. **Direct** picks (home Popular templates, `/templates`) do not wipe a draft on click. **Use without changes** and **Customize** ask before replacing a draft, then seed from the template with no leftover logo or setup answers. **In-flow** picks (`/create/templates?fromFlow=1`) keep the community name, description, and place already given. A hydration latch stops a saved server draft from overwriting the template after apply.
**Direct entry vs in-flow template pick.** The same `/create/review-template/[slug]` URL is reached from two different origins. **Direct** picks (home Popular templates, `/templates`) do not wipe a draft on click. **Use without changes** and **Customize** ask before replacing a draft, then seed from the template. Direct entry drops a leftover logo and setup answers. **In-flow** picks (`/create/templates?fromFlow=1`) keep the community name, description, place, and photo already given. A hydration latch stops a saved server draft from overwriting the template after apply.
| Origin | Click-site behavior | URL the user lands on |
| --- | --- | --- |
+3
View File
@@ -238,6 +238,7 @@ export type TemplateApplyIdentity = {
title?: string;
communityContext?: string;
communityLocation?: string;
communityAvatarUrl?: string;
};
/**
@@ -256,6 +257,7 @@ export function buildAppliedTemplateCreateFlowState(args: {
const title = args.identity?.title?.trim();
const communityContext = args.identity?.communityContext?.trim();
const communityLocation = args.identity?.communityLocation?.trim();
const communityAvatarUrl = args.identity?.communityAvatarUrl?.trim();
const seeded: CreateFlowState = {
...prefill,
@@ -274,6 +276,7 @@ export function buildAppliedTemplateCreateFlowState(args: {
seeded.summary = communityContext;
}
if (communityLocation) seeded.communityLocation = communityLocation;
if (communityAvatarUrl) seeded.communityAvatarUrl = communityAvatarUrl;
if (args.identity) seeded.templateReviewEntryFromCreateFlow = true;
if (args.mode === "useWithoutChanges") {
+22
View File
@@ -248,6 +248,28 @@ describe("buildAppliedTemplateCreateFlowState", () => {
mode: "useWithoutChanges",
});
});
it("keeps an in-flow photo when identity includes it", () => {
const seeded = buildAppliedTemplateCreateFlowState({
slug: "mutual-aid-mondays",
body: {
sections: [
{
categoryName: "Communication",
entries: [{ title: "Signal" }],
},
],
},
mode: "useWithoutChanges",
identity: {
title: "Neighborhood",
communityAvatarUrl: " /api/uploads/logo ",
},
});
expect(seeded.title).toBe("Neighborhood");
expect(seeded.communityAvatarUrl).toBe("/api/uploads/logo");
expect(seeded.templateReviewEntryFromCreateFlow).toBe(true);
});
});
describe("templatePresetDetailsFromPrefill", () => {
@@ -145,12 +145,13 @@ describe("useTemplateReviewActions", () => {
});
});
it("in-flow Use without changes keeps the community name and pins the template path", async () => {
it("in-flow Use without changes keeps the community name, photo, and pins the template path", async () => {
const { result } = renderActions(
{
title: "Neighborhood",
communityContext: "We meet weekly",
templateReviewEntryFromCreateFlow: true,
communityLocation: "Oakland",
communityAvatarUrl: "/api/uploads/logo",
},
true,
);
@@ -162,6 +163,8 @@ describe("useTemplateReviewActions", () => {
expect(router.push).toHaveBeenCalledWith("/create/community-name");
expect(applied?.title).toBe("Neighborhood");
expect(applied?.communityContext).toBe("We meet weekly");
expect(applied?.communityLocation).toBe("Oakland");
expect(applied?.communityAvatarUrl).toBe("/api/uploads/logo");
expect(applied?.setupTraits).toBeUndefined();
expect(applied?.pendingTemplateAction).toEqual({
slug: "mutual-aid-mondays",
@@ -170,6 +173,24 @@ describe("useTemplateReviewActions", () => {
expect(applied?.templateReviewBackSlug).toBe("mutual-aid-mondays");
});
it("a persisted in-flow flag without ?fromFlow=1 clears leftover identity", async () => {
const { result } = renderActions(
{
title: "Neighborhood",
communityAvatarUrl: "/api/uploads/logo",
templateReviewEntryFromCreateFlow: true,
},
false,
);
await act(async () => {
await result.current.handleUseWithoutChanges();
});
expect(applied?.title).toBeUndefined();
expect(applied?.communityAvatarUrl).toBeUndefined();
});
it("asks before replacing a draft in progress", async () => {
requestConfirm.mockResolvedValueOnce(false);
const { result } = renderActions({ title: "Juniper Street Tenants" });