Skip to content

Commit

Permalink
fix: navigate to profile page on back click on mobile (#2274)
Browse files Browse the repository at this point in the history
  • Loading branch information
blushi authored Feb 7, 2024
1 parent 56dadef commit 3c8b84b
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions web-marketplace/src/pages/ProfileEdit/ProfileEdit.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useEffect, useRef, useState } from 'react';
import { Outlet, useNavigate } from 'react-router-dom';
import { Outlet, useLocation, useNavigate } from 'react-router-dom';
import { useTheme } from '@mui/material';
import { useSetAtom } from 'jotai';
import { startCase } from 'lodash';
Expand Down Expand Up @@ -30,7 +30,7 @@ export const ProfileEdit = () => {
const setIsProfileEditDirtyref = useSetAtom(isProfileEditDirtyRef);
const isDirtyRef = useRef<boolean>(false);
const navigate = useNavigate();

const { pathname } = useLocation();
const section = usePathSection();

const onBackClick = (): void => {
Expand All @@ -40,7 +40,12 @@ export const ProfileEdit = () => {
if (isFormDirty) {
setIsWarningModalOpen(path);
} else {
navigate(path);
if (pathname === path) {
// On mobile, we want to navigate back to the profile page
navigate('/profile');
} else {
navigate(path);
}
}
};

Expand Down

0 comments on commit 3c8b84b

Please sign in to comment.