-
-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: warning message before project creation action is cancelled (#924)
* feat: handleInput Change Replaced handlecustomchange with handleinputchanges * feat: SetIsUnsavedChanges added on first submit click * feat: custom hook for handling form exit on create project * feat: list of url to not block for form * feat: isUnsavedChanges action added * feat(CreateProject): prompt for blocking form exit - Fixes Warning message before project creation action is cancelled #700
- Loading branch information
Showing
7 changed files
with
48 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
const pathNotToBlock = ['/select-form', '/data-extract', '/split-tasks', '/upload-area', '/create-project']; | ||
export default pathNotToBlock; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import React from 'react'; | ||
import pathNotToBlock from '../constants/blockerUrl'; | ||
import { unstable_useBlocker as useBlocker } from 'react-router-dom'; | ||
|
||
function Prompt(props) { | ||
const block = props.when; | ||
useBlocker(({ nextLocation }) => { | ||
console.log(nextLocation, 'next'); | ||
if (block && !pathNotToBlock.includes(nextLocation.pathname)) { | ||
return !window.confirm(props.message); | ||
} | ||
return false; | ||
}); | ||
|
||
return <div key={block} />; | ||
} | ||
|
||
export default Prompt; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters