File tree Expand file tree Collapse file tree 2 files changed +15
-7
lines changed
next/src/views/Edit/Default Expand file tree Collapse file tree 2 files changed +15
-7
lines changed Original file line number Diff line number Diff line change @@ -113,10 +113,19 @@ export const DefaultEditView: React.FC = () => {
113
113
114
114
const isLockingEnabled = lockDocumentsProp !== false
115
115
116
- const preventLeaveWithoutSaving =
117
- ( ! ( collectionConfig ?. versions ?. drafts && collectionConfig ?. versions ?. drafts ?. autosave ) ||
118
- ! ( globalConfig ?. versions ?. drafts && globalConfig ?. versions ?. drafts ?. autosave ) ) &&
119
- ! disableLeaveWithoutSaving
116
+ let preventLeaveWithoutSaving = true
117
+
118
+ if ( collectionConfig ) {
119
+ preventLeaveWithoutSaving = ! (
120
+ collectionConfig ?. versions ?. drafts && collectionConfig ?. versions ?. drafts ?. autosave
121
+ )
122
+ } else if ( globalConfig ) {
123
+ preventLeaveWithoutSaving = ! (
124
+ globalConfig ?. versions ?. drafts && globalConfig ?. versions ?. drafts ?. autosave
125
+ )
126
+ } else if ( typeof disableLeaveWithoutSaving !== 'undefined' ) {
127
+ preventLeaveWithoutSaving = ! disableLeaveWithoutSaving
128
+ }
120
129
121
130
const [ isReadOnlyForIncomingUser , setIsReadOnlyForIncomingUser ] = useState ( false )
122
131
const [ showTakeOverModal , setShowTakeOverModal ] = useState ( false )
Original file line number Diff line number Diff line change @@ -47,7 +47,7 @@ export const Autosave: React.FC<Props> = ({
47
47
} = useConfig ( )
48
48
const { docConfig, getVersions, versions } = useDocumentInfo ( )
49
49
const { reportUpdate } = useDocumentEvents ( )
50
- const { dispatchFields, setModified , setSubmitted } = useForm ( )
50
+ const { dispatchFields, setSubmitted } = useForm ( )
51
51
const submitted = useFormSubmitted ( )
52
52
const versionsConfig = docConfig ?. versions
53
53
@@ -149,7 +149,7 @@ export const Autosave: React.FC<Props> = ({
149
149
entitySlug,
150
150
updatedAt : newDate . toISOString ( ) ,
151
151
} )
152
- setModified ( false )
152
+
153
153
void getVersions ( )
154
154
} else {
155
155
return res . json ( )
@@ -247,7 +247,6 @@ export const Autosave: React.FC<Props> = ({
247
247
reportUpdate ,
248
248
serverURL ,
249
249
setSubmitted ,
250
- setModified ,
251
250
versionsConfig ?. drafts ,
252
251
debouncedFields ,
253
252
submitted ,
You can’t perform that action at this time.
0 commit comments