Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: issues with closing editor in dirty state #11094

Merged
merged 3 commits into from
Jun 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Bugfix: Browser confirmation dialog after closing editor

We've fixed a bug where the browser falsely asked the user for confirmation when closing or reloading the page after an editor with unsaved changes had been closed.

https://github.com/owncloud/web/issues/11092
https://github.com/owncloud/web/pull/11094
6 changes: 6 additions & 0 deletions changelog/unreleased/bugfix-button-focus-closing-editor
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Bugfix: Button focus when closing editor

When closing an editor with unsaved changes, the modal now correctly focuses the primary "Save"-button.

https://github.com/owncloud/web/issues/11091
https://github.com/owncloud/web/pull/11094
19 changes: 12 additions & 7 deletions packages/web-pkg/src/components/AppTemplates/AppWrapper.vue
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ import {
useRouteQuery,
useStore,
useSelectedResources,
useSideBar
useSideBar,
useLoadingService
} from '../../composables'
import {
Action,
Expand Down Expand Up @@ -106,6 +107,7 @@ export default defineComponent({
const router = useRouter()
const currentRoute = useRoute()
const clientService = useClientService()
const loadingService = useLoadingService()
const { getResourceContext } = useGetResourceContext()
const { selectedResources } = useSelectedResources({ store })

Expand Down Expand Up @@ -280,12 +282,6 @@ export default defineComponent({
{ immediate: true }
)

onBeforeUnmount(() => {
if (unref(hasProp('url'))) {
revokeUrl(url.value)
}
})

const errorPopup = (error: HttpError) => {
console.error(error)
store.dispatch('showErrorMessage', {
Expand Down Expand Up @@ -378,6 +374,14 @@ export default defineComponent({
}
})
onBeforeUnmount(() => {
if (!loadingService.isLoading) {
window.removeEventListener('beforeunload', preventUnload)
}

if (unref(hasProp('url'))) {
revokeUrl(url.value)
}

if (!unref(isEditor)) {
return
}
Expand Down Expand Up @@ -419,6 +423,7 @@ export default defineComponent({
message: $gettext('Your changes were not saved. Do you want to save them?'),
cancelText: $gettext("Don't Save"),
confirmText: $gettext('Save'),
focusTrapInitial: '.oc-modal-body-actions-confirm',
onCancel() {
store.dispatch('hideModal')
next()
Expand Down
1 change: 1 addition & 0 deletions packages/web-runtime/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
:contextual-helper-label="modal.contextualHelperLabel"
:contextual-helper-data="modal.contextualHelperData"
:hide-actions="modal.hideActions"
:focus-trap-initial="modal.focusTrapInitial"
@cancel="onModalCancel"
@confirm="onModalConfirm"
@input="modal.onInput"
Expand Down
1 change: 1 addition & 0 deletions packages/web-runtime/src/store/modal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ const mutations = {
state.customComponentAttrs = modal.customComponentAttrs
state.customContent = modal.customContent || ''
state.hideActions = modal.hideActions || false
state.focusTrapInitial = modal.focusTrapInitial
},

HIDE_MODAL(state) {
Expand Down