Skip to content

Commit 5d2fce3

Browse files
committed
Fix: Added backward navigation in setup wizard registration form
1 parent 0bec138 commit 5d2fce3

2 files changed

Lines changed: 10 additions & 1 deletion

File tree

apps/meteor/client/views/root/MainLayout/RegisterUsername.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import {
1111
useToastMessageDispatch,
1212
useAssetWithDarkModePath,
1313
useAccountsCustomFields,
14+
useRouter, // ✅ ADDED
1415
} from '@rocket.chat/ui-contexts';
1516
import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query';
1617
import { useEffect, useId } from 'react';
@@ -26,6 +27,7 @@ const RegisterUsername = () => {
2627
const t = useTranslation();
2728
const uid = useUserId();
2829
const logout = useLogout();
30+
const router = useRouter(); // ✅ ADDED
2931
const formLabelId = useId();
3032
const hideLogo = useSetting('Layout_Login_Hide_Logo', false);
3133
const customLogo = useAssetWithDarkModePath('logo');
@@ -125,6 +127,9 @@ const RegisterUsername = () => {
125127
</Form.Container>
126128
<Form.Footer>
127129
<ButtonGroup stretch vertical>
130+
<Button onClick={() => router.navigate(-1)}> {/* ✅ BACK BUTTON ADDED */}
131+
Back
132+
</Button>
128133
<Button disabled={isLoading} type='submit' primary>
129134
{t('Use_this_username')}
130135
</Button>

apps/meteor/client/views/root/hooks/useRedirectToSetupWizard.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,16 @@ export const useRedirectToSetupWizard = (): void => {
55
const userId = useUserId();
66
const setupWizardState = useSetting('Show_Setup_Wizard');
77
const router = useRouter();
8+
89
const isAdmin = useRole('admin');
910

1011
const isWizardInProgress = userId && isAdmin && setupWizardState === 'in_progress';
1112
const mustRedirect = (!userId && setupWizardState === 'pending') || isWizardInProgress;
13+
1214
useEffect(() => {
13-
if (mustRedirect) {
15+
const currentPath = router.getLocationPathname();
16+
//DO NOT Redirect if already inside setup wizard (Fixes navigation)
17+
if (mustRedirect && !currentPath?.startsWith('/setup-wizard')) {
1418
router.navigate('/setup-wizard');
1519
}
1620
}, [mustRedirect, router]);

0 commit comments

Comments
 (0)