Repository navigation
Description
What happened?
Calling hide() on the object returned by $q.dialog() or $q.bottomSheet() throws once the dialog has already been dismissed:
Uncaught (in promise) TypeError: Cannot read properties of null (reading '$')
When the dialog hides, onHide in ui/src/utils/private.dialog/create-dialog.js unmounts the child app and sets vm = null, and Vue clears dialogRef. A later hide() goes through applyState('hide'), which finds no dialogRef.value and falls back to walking vm.$.subTree on the released vm. update() on the same object already checks vm !== null and does nothing in this state. hide() has no such check.
This comes up whenever app code hides a dialog that the user may already have closed. A typical case is a try/finally around an async task, or a route-leave hook:
const dialog = $q.dialog({ message: 'Saving...', progress: true, ok: false })
try {
await save()
} finally {
dialog.hide() // throws if the user pressed ESC / clicked the backdrop meanwhile
}The TypeError comes out of the finally block and replaces the result of save(). The caller sees a crash even when the save succeeded.
What did you expect to happen?
hide() should do nothing when the dialog is already gone, the same way update() does, and still return the chain object.
Reproduction URL
Self-contained HTML below (Vue 3 and Quasar 2.36.0 UMD from jsDelivr)
How to reproduce?
<!DOCTYPE html>
<html>
<head>
<link href="https://cdn.jsdelivr.net/npm/quasar@2.36.0/dist/quasar.prod.css" rel="stylesheet">
</head>
<body>
<div id="app">
<q-btn label="Save" color="primary" @click="save"></q-btn>
</div>
<script src="https://cdn.jsdelivr.net/npm/vue@3/dist/vue.global.prod.js"></script>
<script src="https://cdn.jsdelivr.net/npm/quasar@2.36.0/dist/quasar.umd.prod.js"></script>
<script>
const app = Vue.createApp({
setup() {
const $q = Quasar.useQuasar()
async function save() {
const dialog = $q.dialog({ message: 'Saving...', progress: true, ok: false })
try {
await new Promise(resolve => setTimeout(resolve, 3000))
} finally {
dialog.hide()
}
}
return { save }
}
})
app.use(Quasar)
app.mount('#app')
</script>
</body>
</html>- Open the page and click "Save".
- Press ESC (or click the backdrop) within 3 seconds.
- When the 3 seconds are up, the console shows the
TypeErrorabove.
$q.bottomSheet() behaves the same, since both plugins share createDialog().
Flavour
UMD
Platforms/Browsers
Chrome
Versions
quasar 2.36.0 (same code on dev), vue 3.5
Relevant log output
Uncaught (in promise) TypeError: Cannot read properties of null (reading '$')
Additional context
It does not depend on the flavour or the browser: it is a null dereference in createDialog(). The UMD page above is only the shortest way to reproduce it.
Activity