File tree Expand file tree Collapse file tree 1 file changed +10
-6
lines changed
packages/react-filerobot-image-editor/src/components/Topbar Expand file tree Collapse file tree 1 file changed +10
-6
lines changed Original file line number Diff line number Diff 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 , {
You can’t perform that action at this time.
0 commit comments