Skip to content

Commit

Permalink
Fix dialog not appearing when another modal is open
Browse files Browse the repository at this point in the history
Signed-off-by: Christopher Ng <[email protected]>
  • Loading branch information
Pytal committed Sep 10, 2022
1 parent 26fc54a commit f72c044
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 10 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.

## Unreleased

### Fixed

- Fix dialog not appearing when another modal is open

## 3.0.0 - 2022-09-07

### Breaking
Expand Down
14 changes: 7 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"@nextcloud/capabilities": "^1.0.4",
"@nextcloud/l10n": "^1.6.0",
"@nextcloud/router": "^2.0.0",
"@nextcloud/vue": "^7.0.0-beta.0",
"@nextcloud/vue": "^7.0.0-beta.2",
"vue": "^2.7.10"
},
"devDependencies": {
Expand Down
1 change: 1 addition & 0 deletions src/components/Dialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
<NcModal :id="dialogId"
class="dialog"
size="small"
:container="null"
@close="close">
<div class="dialog__container">
<h2 class="dialog__title">{{ titleText }}</h2>
Expand Down
1 change: 1 addition & 0 deletions src/globals.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export const DIALOG_ID = 'password-confirmation-dialog'
export const MODAL_CLASS = 'modal-mask' // NcModal component root class https://github.com/nextcloud/nextcloud-vue/blob/v7.0.0-beta.2/src/components/NcModal/NcModal.vue
13 changes: 11 additions & 2 deletions src/main.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Vue from 'vue'
import DialogComponent from './components/Dialog.vue'
import { DIALOG_ID } from './globals.js'
import { DIALOG_ID, MODAL_CLASS } from './globals.js'
import { t } from './utils/l10n.js'

import type { ComponentInstance } from 'vue'
Expand All @@ -27,7 +27,16 @@ export const confirmPassword = (): Promise<void> => {

const mountPoint = document.createElement('div')
mountPoint.setAttribute('id', DIALOG_ID)
document.body.prepend(mountPoint)

const modals = document.querySelectorAll(`.${MODAL_CLASS}`)
const isModalMounted = Boolean(modals.length)

if (isModalMounted) {
const previousModal = modals[modals.length - 1]
previousModal.prepend(mountPoint)
} else {
document.body.prepend(mountPoint)
}

const DialogClass = Vue.extend(DialogComponent)
// Mount point element is replaced by the component
Expand Down

0 comments on commit f72c044

Please sign in to comment.