Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions src/pages/start.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { useState, useRef, useCallback } from 'react';
import { useTheme } from '@emotion/react';
import { Box, Grid, Stack, Typography } from '@mui/material';
import React from 'react';
import { useRouter } from 'next/router';

// confetti
import Confetti from 'react-confetti';
Expand Down Expand Up @@ -65,6 +66,7 @@ const getTemplate = async (zuid, setrepository, isProduction) => {
});
};
export default function Start(props) {
const router = useRouter();
const params = new URLSearchParams(
typeof window !== 'undefined' && window.location.search,
);
Expand Down Expand Up @@ -102,10 +104,16 @@ export default function Start(props) {
const handlePrev = useCallback(() => {
if (currentStep > 1) {
setCurrentStep(currentStep - 1);

if (sliderRef.current) {
sliderRef.current.swiper.slidePrev();
}

return;
}
if (!sliderRef.current) return;
sliderRef.current.swiper.slidePrev();
}, [currentStep]);

router.back();
Comment thread
finnar-bin marked this conversation as resolved.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

router.back() is a no-op when there's no in-app history — e.g., if the user lands on /start directly via a shared link, email/marketing campaign, or new tab. In that case clicking the back chevron does nothing and the user is stuck on step 1 with no way to "exit".

Consider falling back to a known route when there's no history:

if (window.history.length > 1) {
  router.back();
} else {
  router.push('/');
}

Same caveat applies if the previous entry was external (e.g., Google) — router.back() will navigate the user off the site entirely, which may or may not be the intended "exit" behavior.

}, [currentStep, router]);

// moves user forward a slide in the onboard process
const handleNext = useCallback(() => {
Expand Down
Loading