@@ -93,7 +93,7 @@ class DrawerChild extends React.Component<IDrawerChildProps, IState> {
93
93
} catch ( err ) { }
94
94
this . passive = passiveSupported ? { passive : false } : false ;
95
95
}
96
- const { open, getContainer, showMask } = this . props ;
96
+ const { open, getContainer, showMask, autoFocus } = this . props ;
97
97
const container = getContainer && getContainer ( ) ;
98
98
this . drawerId = `drawer_id_${ Number (
99
99
( Date . now ( ) + Math . random ( ) )
@@ -108,7 +108,9 @@ class DrawerChild extends React.Component<IDrawerChildProps, IState> {
108
108
// 默认打开状态时推出 level;
109
109
this . openLevelTransition ( ) ;
110
110
this . forceUpdate ( ( ) => {
111
- this . domFocus ( ) ;
111
+ if ( autoFocus ) {
112
+ this . domFocus ( ) ;
113
+ }
112
114
} ) ;
113
115
if ( showMask ) {
114
116
this . props . scrollLocker ?. lock ( ) ;
@@ -117,15 +119,23 @@ class DrawerChild extends React.Component<IDrawerChildProps, IState> {
117
119
}
118
120
119
121
public componentDidUpdate ( prevProps : IDrawerChildProps ) {
120
- const { open, getContainer, scrollLocker, showMask } = this . props ;
122
+ const {
123
+ open,
124
+ getContainer,
125
+ scrollLocker,
126
+ showMask,
127
+ autoFocus,
128
+ } = this . props ;
121
129
const container = getContainer && getContainer ( ) ;
122
130
if ( open !== prevProps . open ) {
123
131
if ( container && container . parentNode === document . body ) {
124
132
currentDrawer [ this . drawerId ] = ! ! open ;
125
133
}
126
134
this . openLevelTransition ( ) ;
127
135
if ( open ) {
128
- this . domFocus ( ) ;
136
+ if ( autoFocus ) {
137
+ this . domFocus ( ) ;
138
+ }
129
139
if ( showMask ) {
130
140
scrollLocker ?. lock ( ) ;
131
141
}
@@ -547,7 +557,7 @@ class DrawerChild extends React.Component<IDrawerChildProps, IState> {
547
557
msTransform : transform ,
548
558
width : isNumeric ( width ) ? `${ width } px` : width ,
549
559
height : isNumeric ( height ) ? `${ height } px` : height ,
550
- ...contentWrapperStyle
560
+ ...contentWrapperStyle ,
551
561
} }
552
562
ref = { c => {
553
563
this . contentWrapper = c as HTMLElement ;
0 commit comments