Skip to content

Commit 63c4d08

Browse files
committed
fix: enter edit mode with url
1 parent 0bc441a commit 63c4d08

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

frontend/src/pages/agreements/details/Agreement.jsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { useCallback, useEffect, useState } from "react";
1+
import { useCallback, useEffect, useRef, useState } from "react";
22
import { useSelector } from "react-redux";
33
import { Route, Routes, useLocation, useNavigate, useParams } from "react-router-dom";
44
import App from "../../../App";
@@ -84,8 +84,12 @@ const Agreement = () => {
8484
}, [isEditMode]);
8585

8686
// Exit edit mode when navigating between tabs
87+
const previousPathnameRef = useRef(location.pathname);
8788
useEffect(() => {
88-
setIsEditMode((prev) => (prev ? false : prev));
89+
if (previousPathnameRef.current !== location.pathname) {
90+
previousPathnameRef.current = location.pathname;
91+
setIsEditMode((prev) => (prev ? false : prev));
92+
}
8993
}, [location.pathname]);
9094

9195
/** @type {{data?: import("../../../types/AgreementTypes").Agreement | undefined, error?: Object, isLoading: boolean, isSuccess: boolean}} */

0 commit comments

Comments
 (0)