Skip to content

Commit 904d429

Browse files
author
Thomas Leconte
committed
Fix: Promise leak when click outside of non-persistent dialog
1 parent 4cdcfe2 commit 904d429

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

cypress/test-server/src/components/HelloWorld.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ export default defineComponent({
8484
{ key: 'button1', title: 'Button 1', variant: 'outlined', color: 'error' },
8585
{ key: 'button2', title: 'Button 2', variant: 'tonal', color: 'success' }
8686
]
87-
})
87+
}).then((key: any) => console.log(key))
8888
},
8989
createCustomComponentDialog(){
9090
this.$dialog.create({

src/components/Dialog.vue

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<script setup lang="ts">
22
import { ComponentOptions } from 'types';
3-
import { Component, PropType, ref } from 'vue';
3+
import { Component, PropType, ref, watch } from 'vue';
44
import { VDialog } from 'vuetify/lib/components/index.mjs';
55
import Card from './Card.vue';
66
@@ -49,6 +49,13 @@ function close(buttonKey: string | boolean){
4949
showDialog.value = false
5050
emit('closeDialog', buttonKey)
5151
}
52+
53+
// ------- WATCH ---------
54+
watch((showDialog), (newValue) => {
55+
if(!newValue){
56+
close(false)
57+
}
58+
})
5259
</script>
5360

5461

@@ -72,4 +79,4 @@ function close(buttonKey: string | boolean){
7279
@buttonClicked="close"
7380
/>
7481
</VDialog>
75-
</template>
82+
</template>

0 commit comments

Comments
 (0)