Skip to content

Commit 52c86fe

Browse files
markgohoclaude
andcommitted
fix: wizard step width and premature redirect after profile creation
Routed step components were not filling the wizard container width because Angular renders them as siblings of <router-outlet>. Added CSS rule to ensure full-width rendering. After the contact step saved the profile, reloadUserDocument() caused the profileCreatedAt guard to immediately redirect to /profile, skipping the image and preview steps. The redirect now checks wizardService.profileCreated to distinguish "just created during wizard" from "already had a profile". Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 26faa7b commit 52c86fe

3 files changed

Lines changed: 44 additions & 2 deletions

File tree

members/src/app/create-profile-wizard/create-profile-wizard.scss

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@
33
container: profileform / inline-size;
44
}
55

6+
router-outlet + * {
7+
display: block;
8+
width: 100%;
9+
}
10+
611
.loading-message {
712
text-align: center;
813
padding: var(--space-xl);

members/src/app/create-profile-wizard/create-profile-wizard.spec.ts

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,42 @@ describe('CreateProfileWizard', () => {
153153
expect(wizardService.personalInfo().title).toBe('');
154154
});
155155

156+
it('should not redirect to /profile when profile was just created during wizard flow', async () => {
157+
const { wizardService, mockMembershipService, router } = await setup({
158+
userDocumentLoading: true,
159+
});
160+
const navigateSpy = vi.spyOn(router, 'navigate').mockResolvedValue(true);
161+
162+
// Simulate member loading without profileCreatedAt (new user starting wizard)
163+
const member: Member = {
164+
uid: 'test-uid',
165+
email: 'test@example.com',
166+
name: 'Test User',
167+
createdAt: new Date(0),
168+
isAdmin: false,
169+
membershipActive: true,
170+
slug: 'test-user',
171+
};
172+
mockMembershipService.userDocument.set(member);
173+
TestBed.flushEffects();
174+
175+
// Simulate the contact step completing: profile was created during this wizard session
176+
wizardService.profileCreated.set(true);
177+
wizardService.completeStep('contact');
178+
TestBed.flushEffects();
179+
180+
// Simulate reloadUserDocument() updating the member with profileCreatedAt
181+
// This is what profileService.createProfileContent() does after saving
182+
mockMembershipService.userDocument.set({
183+
...member,
184+
profileCreatedAt: new Date(),
185+
});
186+
TestBed.flushEffects();
187+
188+
// Should NOT redirect — the user needs to finish the image and preview steps
189+
expect(navigateSpy).not.toHaveBeenCalledWith(['/profile']);
190+
});
191+
156192
it('should reset wizard state on destroy', async () => {
157193
const { wizardService, fixture } = await setup();
158194

members/src/app/create-profile-wizard/create-profile-wizard.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,11 @@ export class CreateProfileWizard {
5252
// Reset wizard state when leaving the wizard
5353
this.destroyRef.onDestroy(() => this.wizardService.reset());
5454

55-
// Redirect to /profile if user already has a profile
55+
// Redirect to /profile if user already has a profile (before entering the wizard)
56+
// Skip redirect if the profile was just created during this wizard session
5657
effect(() => {
5758
const user = this.userDocument();
58-
if (user?.profileCreatedAt) {
59+
if (user?.profileCreatedAt && !this.wizardService.profileCreated()) {
5960
void this.router.navigate(['/profile']);
6061
}
6162
});

0 commit comments

Comments
 (0)