breadit icon indicating copy to clipboard operation
breadit copied to clipboard

Fix Modal Navigation

Open robharding opened this issue 2 years ago • 5 comments

Hi Josh, thanks for the great tutorial. I was having issues getting the modals to behave as expected. To reproduce bring up the sign in modal, and then click the sign up button. If you try closing the sign out modal, it brings you back to the sign in modal instead of the expected page. My fix is to replace the page in the router instead of navigating.

robharding avatar Jun 16 '23 13:06 robharding

forgot- both files will now need "use client"; on the first line because we are using the onClick hook.

robharding avatar Jun 16 '23 13:06 robharding

This broke navigation when opening a modal from the sign up/sign in page, as closing the modal would take you to where you were before that page(not the page itself).

robharding avatar Jun 16 '23 14:06 robharding

Awesome thanks for the PR, gonna look into it as soon as I find the time

joschan21 avatar Jun 16 '23 19:06 joschan21

Instead of onClick, the SignIn and SignUp can use the replace property to replace the current route in the case it's already on a modal.

robharding avatar Jun 19 '23 13:06 robharding

Thanks, works well!

JulianBristol avatar Sep 11 '23 18:09 JulianBristol