mirror of
https://github.com/sasjs/server.git
synced 2025-12-10 19:34:34 +00:00
fix(web): when no file is selected save the editor content to local storage
This commit is contained in:
@@ -102,7 +102,7 @@ const SASjsEditor = ({
|
||||
|
||||
usePrompt(
|
||||
'Changes you made may not be saved.',
|
||||
prevFileContent !== fileContent
|
||||
prevFileContent !== fileContent && !!selectedFilePath
|
||||
)
|
||||
|
||||
useEffect(() => {
|
||||
@@ -134,11 +134,18 @@ const SASjsEditor = ({
|
||||
})
|
||||
.finally(() => setIsLoading(false))
|
||||
} else {
|
||||
setFileContent('')
|
||||
const content = localStorage.getItem('fileContent') ?? ''
|
||||
setFileContent(content)
|
||||
}
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [selectedFilePath])
|
||||
|
||||
useEffect(() => {
|
||||
if (fileContent.length && !selectedFilePath) {
|
||||
localStorage.setItem('fileContent', fileContent)
|
||||
}
|
||||
}, [fileContent, selectedFilePath])
|
||||
|
||||
useEffect(() => {
|
||||
if (runTimes.includes(selectedFileExtension))
|
||||
setSelectedRunTime(selectedFileExtension)
|
||||
|
||||
Reference in New Issue
Block a user