diff --git a/changelog/unreleased/enhancement-add-cancel-button-to-unsaved-changes-dialog b/changelog/unreleased/enhancement-add-cancel-button-to-unsaved-changes-dialog
new file mode 100644
index 00000000000..4ad391e2fc4
--- /dev/null
+++ b/changelog/unreleased/enhancement-add-cancel-button-to-unsaved-changes-dialog
@@ -0,0 +1,6 @@
+Enhancement: Add cancel button to unsaved changes dialog
+
+We've added a cancel button to the unsaved changes dialog to allow users to cancel the action.
+
+https://github.com/owncloud/web/pull/11644
+https://github.com/owncloud/web/issues/11636
diff --git a/packages/web-pkg/src/components/AppTemplates/AppWrapper.vue b/packages/web-pkg/src/components/AppTemplates/AppWrapper.vue
index c189c1f4788..3b36b956aec 100644
--- a/packages/web-pkg/src/components/AppTemplates/AppWrapper.vue
+++ b/packages/web-pkg/src/components/AppTemplates/AppWrapper.vue
@@ -90,6 +90,7 @@ import { DavPermission } from '@ownclouders/web-client/webdav'
import { HttpError } from '@ownclouders/web-client'
import { dirname } from 'path'
import { useFileActionsOpenWithApp } from '../../composables/actions/files/useFileActionsOpenWithApp'
+import { UnsavedChangesModal } from '../Modals'
export default defineComponent({
name: 'AppWrapper',
@@ -544,15 +545,17 @@ export default defineComponent({
onBeforeRouteLeave((_to, _from, next) => {
if (unref(isDirty)) {
dispatchModal({
- variation: 'danger',
- icon: 'warning',
+ icon: 'error-warning',
title: $gettext('Unsaved changes'),
- message: $gettext('Your changes were not saved. Do you want to save them?'),
- cancelText: $gettext("Don't Save"),
- confirmText: $gettext('Save'),
+ customComponent: UnsavedChangesModal,
focusTrapInitial: '.oc-modal-body-actions-confirm',
- onCancel() {
- next()
+ hideActions: true,
+ customComponentAttrs: () => {
+ return {
+ closeCallback: async () => {
+ next()
+ }
+ }
},
async onConfirm() {
await save()
diff --git a/packages/web-pkg/src/components/Modals/UnsavedChangesModal.vue b/packages/web-pkg/src/components/Modals/UnsavedChangesModal.vue
new file mode 100644
index 00000000000..35851db4dc3
--- /dev/null
+++ b/packages/web-pkg/src/components/Modals/UnsavedChangesModal.vue
@@ -0,0 +1,57 @@
+
+
+
+