Skip to content

Commit d84942c

Browse files
committed
fix: dont show confirmation modal if avoidChangesNotSavedAlertOnLeave is set to true
Signed-off-by: Hamza <hamzamahjoubi221@gmail.com>
1 parent 3d198dd commit d84942c

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

packages/react-filerobot-image-editor/src/components/Topbar/ConfirmationModal.jsx

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ const ConfirmationModal = ({ children, isReset }) => {
1717
dispatch,
1818
isResetted = true,
1919
haveNotSavedChanges,
20-
config: { onClose },
20+
config: { onClose, avoidChangesNotSavedAlertOnLeave },
2121
} = useStore();
2222

2323
const [isModalOpened, setIsModalOpened] = useState(false);
@@ -32,11 +32,6 @@ const ConfirmationModal = ({ children, isReset }) => {
3232
const cancelModal = () => {
3333
setIsModalOpened(false);
3434
};
35-
36-
const openModal = () => {
37-
setIsModalOpened(true);
38-
};
39-
4035
const dispatchReset = useCallback(() => {
4136
dispatch({ type: RESET, payload: { config } });
4237
cancelModal();
@@ -49,6 +44,15 @@ const ConfirmationModal = ({ children, isReset }) => {
4944
dispatchReset();
5045
};
5146

47+
const openModal = () => {
48+
// Don't open the modal if avoidChangesNotSavedAlertOnLeave is true
49+
if (avoidChangesNotSavedAlertOnLeave) {
50+
closeWithReason();
51+
return;
52+
}
53+
setIsModalOpened(true);
54+
};
55+
5256
return (
5357
<>
5458
{React.cloneElement(children, {

0 commit comments

Comments
 (0)