Skip to content

Commit fa6f093

Browse files
authored
Merge pull request #154 from GursheenK/popstate-listener-for-dialog-close
fix: handle popstate event for theme dialog closing
2 parents f515247 + 5bcb5ad commit fa6f093

1 file changed

Lines changed: 21 additions & 4 deletions

File tree

frontend/src/pages/PresentationEditor.vue

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,11 @@ const handleMounted = () => {
231231
loadTemplates()
232232
}
233233
234+
const hideOpenDialogs = () => {
235+
showThemeDialog.value = false
236+
showLayoutDialog.value = false
237+
}
238+
234239
const handleBeforeUnmount = () => {
235240
updateUnsyncedRecord()
236241
clearInterval(autosaveInterval)
@@ -241,6 +246,7 @@ const handleBeforeUnmount = () => {
241246
syncPresentationToServer()
242247
}
243248
window.removeEventListener('beforeunload', handleBeforeUnload)
249+
window.removeEventListener('popstate', hideOpenDialogs)
244250
}
245251
246252
watch(
@@ -262,10 +268,10 @@ watch(
262268
)
263269
264270
watch(
265-
() => props.presentationId,
266-
(id) => {
271+
() => route.name,
272+
(name) => {
267273
inReadonlyMode.value = props.editorAccess == 'view'
268-
if (route.name === 'EditorNew') {
274+
if (name === 'EditorNew') {
269275
resetEditorState()
270276
themeDialogAction.value = 'create'
271277
showThemeDialog.value = true
@@ -276,10 +282,21 @@ watch(
276282
{ immediate: true },
277283
)
278284
285+
watch(
286+
() => props.presentationId,
287+
(id, prevId) => {
288+
if (!id || !prevId || id === prevId) return
289+
inReadonlyMode.value = props.editorAccess == 'view'
290+
loadEditorState()
291+
},
292+
)
293+
279294
onBeforeRouteLeave(() => {
280-
showThemeDialog.value = false
295+
hideOpenDialogs()
281296
})
282297
298+
window.addEventListener('popstate', hideOpenDialogs)
299+
283300
watch(
284301
() => props.editorAccess,
285302
(doc) => {

0 commit comments

Comments
 (0)