jcmcneal / react-step-wizard

A modern flexible step wizard component built for React.
MIT License
583 stars 126 forks source link

Back Button for Step 1 #46

Closed thadrinks closed 2 years ago

thadrinks commented 4 years ago

After switching to step 2, the url adds #step2. When I hit the back button, it returns back to the original url which doesn't do the transition back to step1 at all. Is there a way to have the back button work on step1 after transitioning to step2?

Thanks!

raduchiu commented 4 years ago

I have the same problem.

rpresb commented 3 years ago

It's strange as I have the same issue, but I did download the code and it doesn't happen in my forked version. Will dig a bit into this to see what's causing this issue.

rpresb commented 3 years ago

I found the reason of failure on my side.

I had this code before

        <a
            href='#'
            onClick={() => {
                console.log(`Going back to ${title}`);
                onClick && onClick();
                previousStep();
            }}
        >
            &lt; return to {title}
        </a>

But I wasn't preventing the default behaviour of the link.

Fixed code:

        <a
            href='#'
            onClick={(e) => {
                e.preventDefault();
                console.log(`Going back to ${title}`);
                onClick && onClick();
                previousStep();
            }}
        >
            &lt; return to {title}
        </a>
petecroaker commented 3 years ago

this still seems to be occurring...