@@ -14,7 +14,7 @@ import useDrag from './hooks/useDrag';
1414import { parseWidthHeight } from './util' ;
1515import type { DrawerClassNames , DrawerStyles } from './inter' ;
1616import { useEvent } from '@rc-component/util' ;
17- import { useLockFocus } from '@rc-component/util/lib/Dom/focus ' ;
17+ import useFocusable from './hooks/useFocusable ' ;
1818
1919export type Placement = 'left' | 'right' | 'top' | 'bottom' ;
2020
@@ -23,7 +23,7 @@ export interface PushConfig {
2323}
2424
2525export interface FocusableConfig {
26- autoFocus ?: boolean | string ;
26+ autoFocus ?: boolean ;
2727 focusTriggerAfterClose ?: boolean ;
2828 trap ?: boolean ;
2929}
@@ -105,7 +105,10 @@ const DrawerPopup: React.ForwardRefRenderFunction<
105105 inline,
106106 push,
107107 forceRender,
108+
109+ // Focus
108110 autoFocus,
111+ focusable,
109112
110113 // classNames
111114 classNames : drawerClassNames ,
@@ -153,15 +156,8 @@ const DrawerPopup: React.ForwardRefRenderFunction<
153156
154157 React . useImperativeHandle ( ref , ( ) => panelRef . current ) ;
155158
156- useLockFocus ( open , ( ) => panelRef . current ) ;
157-
158- // ========================== Control ===========================
159- // Auto Focus
160- React . useEffect ( ( ) => {
161- if ( open && autoFocus ) {
162- panelRef . current ?. focus ( { preventScroll : true } ) ;
163- }
164- } , [ open ] ) ;
159+ // ========================= Focusable ==========================
160+ useFocusable ( ( ) => panelRef . current , open , focusable , autoFocus , mask ) ;
165161
166162 // ============================ Push ============================
167163 const [ pushed , setPushed ] = React . useState ( false ) ;
0 commit comments