File tree 2 files changed +27
-3
lines changed
2 files changed +27
-3
lines changed Original file line number Diff line number Diff line change @@ -80,6 +80,11 @@ const Drawer = {
80
80
}
81
81
} ,
82
82
methods : {
83
+ domFocus ( ) {
84
+ if ( this . $refs . vcDrawer ) {
85
+ this . $refs . vcDrawer . domFocus ( ) ;
86
+ }
87
+ } ,
83
88
close ( e ) {
84
89
this . $emit ( 'close' , e ) ;
85
90
} ,
@@ -95,9 +100,14 @@ const Drawer = {
95
100
} ) ;
96
101
} ,
97
102
pull ( ) {
98
- this . setState ( {
99
- _push : false ,
100
- } ) ;
103
+ this . setState (
104
+ {
105
+ _push : false ,
106
+ } ,
107
+ ( ) => {
108
+ this . domFocus ( ) ;
109
+ } ,
110
+ ) ;
101
111
} ,
102
112
onDestroyTransitionEnd ( ) {
103
113
const isDestroyOnClose = this . getDestroyOnClose ( ) ;
@@ -211,6 +221,7 @@ const Drawer = {
211
221
const prefixCls = getPrefixCls ( 'drawer' , customizePrefixCls ) ;
212
222
213
223
const vcDrawerProps = {
224
+ ref : 'vcDrawer' ,
214
225
props : {
215
226
...omit ( rest , [
216
227
'closable' ,
Original file line number Diff line number Diff line change @@ -85,6 +85,9 @@ const Drawer = {
85
85
this . getDefault ( this . $props ) ;
86
86
if ( open ) {
87
87
this . isOpenChange = true ;
88
+ this . $nextTick ( ( ) => {
89
+ this . domFocus ( ) ;
90
+ } ) ;
88
91
}
89
92
this . $forceUpdate ( ) ;
90
93
}
@@ -103,6 +106,11 @@ const Drawer = {
103
106
} ) ;
104
107
}
105
108
this . preProps . open = val ;
109
+ if ( val ) {
110
+ this . $nextTick ( ( ) => {
111
+ this . domFocus ( ) ;
112
+ } ) ;
113
+ }
106
114
} ,
107
115
placement ( val ) {
108
116
if ( val !== this . preProps . placement ) {
@@ -140,6 +148,11 @@ const Drawer = {
140
148
clearTimeout ( this . timeout ) ;
141
149
} ,
142
150
methods : {
151
+ domFocus ( ) {
152
+ if ( this . dom ) {
153
+ this . dom . focus ( ) ;
154
+ }
155
+ } ,
143
156
onKeyDown ( e ) {
144
157
if ( e . keyCode === KeyCode . ESC ) {
145
158
e . stopPropagation ( ) ;
You can’t perform that action at this time.
0 commit comments