Commit e1990a70 authored by zj9495's avatar zj9495 Committed by GitHub

Fix drawer destroy (#20715)

* Drawer: fix destroyOnClose bug
parent 4ed7ac67
......@@ -136,7 +136,12 @@ export default {
}
this.prevActiveElement = document.activeElement;
} else {
if (!this.closed) this.$emit('close');
if (!this.closed) {
this.$emit('close');
if (this.destroyOnClose === true) {
this.rendered = false;
}
}
this.$nextTick(() => {
if (this.prevActiveElement) {
this.prevActiveElement.focus();
......
......@@ -132,6 +132,30 @@ describe('Drawer', () => {
expect(vm.$el.querySelector('.el-drawer__body')).not.to.exist;
});
it('should destroy every child by visible change when destroy-on-close flag is true', async() => {
vm = createVue({
template: `
<el-drawer :title='title' :visible='visible' :append-to-body='true' :destroy-on-close='true' ref='drawer'>
<span>${content}</span>
</el-drawer>
`,
data() {
return {
title,
visible: true
};
}
});
await waitImmediate();
expect(vm.$el.querySelector('.el-drawer__body span').textContent).to.equal(
content
);
vm.visible = false;
await wait(400);
expect(vm.$el.querySelector('.el-drawer__body')).not.to.exist;
});
it('should close dialog by clicking the close button', async() => {
vm = createVue({
template: `
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment