Remove modal after closed

This commit is contained in:
Pig Fang 2019-12-01 14:45:33 +08:00
parent 6cd5e9a1e7
commit beec114717
2 changed files with 10 additions and 1 deletions

View File

@ -41,6 +41,11 @@ export function showModal(options: ModalOptions = {}): Promise<ModalResult> {
}), }),
}).$mount(container) }).$mount(container)
$(instance.$el).modal('show') $(instance.$el)
.modal('show')
.on('hidden.bs.modal', () => {
instance.$el.remove()
instance.$destroy()
})
}) })
} }

View File

@ -1,3 +1,4 @@
import $ from 'jquery'
import { showModal } from '@/scripts/modal' import { showModal } from '@/scripts/modal'
test('show modal', async () => { test('show modal', async () => {
@ -9,4 +10,7 @@ test('show modal', async () => {
}) })
const { value } = await showModal() const { value } = await showModal()
expect(value).toBe('') expect(value).toBe('')
$('.modal').trigger('hidden.bs.modal')
expect(document.querySelector('.modal')).toBeNull()
}) })