File tree Expand file tree Collapse file tree 2 files changed +30
-1
lines changed Expand file tree Collapse file tree 2 files changed +30
-1
lines changed Original file line number Diff line number Diff line change @@ -136,7 +136,12 @@ export default {
136
136
}
137
137
this .prevActiveElement = document .activeElement ;
138
138
} else {
139
- if (! this .closed ) this .$emit (' close' );
139
+ if (! this .closed ) {
140
+ this .$emit (' close' );
141
+ if (this .destroyOnClose === true ) {
142
+ this .rendered = false ;
143
+ }
144
+ }
140
145
this .$nextTick (() => {
141
146
if (this .prevActiveElement ) {
142
147
this .prevActiveElement .focus ();
Original file line number Diff line number Diff line change @@ -132,6 +132,30 @@ describe('Drawer', () => {
132
132
expect ( vm . $el . querySelector ( '.el-drawer__body' ) ) . not . to . exist ;
133
133
} ) ;
134
134
135
+ it ( 'should destroy every child by visible change when destroy-on-close flag is true' , async ( ) => {
136
+ vm = createVue ( {
137
+ template : `
138
+ <el-drawer :title='title' :visible='visible' :append-to-body='true' :destroy-on-close='true' ref='drawer'>
139
+ <span>${ content } </span>
140
+ </el-drawer>
141
+ ` ,
142
+ data ( ) {
143
+ return {
144
+ title,
145
+ visible : true
146
+ } ;
147
+ }
148
+ } ) ;
149
+
150
+ await waitImmediate ( ) ;
151
+ expect ( vm . $el . querySelector ( '.el-drawer__body span' ) . textContent ) . to . equal (
152
+ content
153
+ ) ;
154
+ vm . visible = false ;
155
+ await wait ( 400 ) ;
156
+ expect ( vm . $el . querySelector ( '.el-drawer__body' ) ) . not . to . exist ;
157
+ } ) ;
158
+
135
159
it ( 'should close dialog by clicking the close button' , async ( ) => {
136
160
vm = createVue ( {
137
161
template : `
You can’t perform that action at this time.
0 commit comments