@@ -7,17 +7,6 @@ import type { IDialogPropTypes } from '../../IDialogPropTypes';
77import MemoChildren from './MemoChildren' ;
88import pickAttrs from '@rc-component/util/lib/pickAttrs' ;
99
10- const sentinelStyle : React . CSSProperties = {
11- width : 0 ,
12- height : 0 ,
13- overflow : 'hidden' ,
14- outline : 'none' ,
15- } ;
16-
17- const entityStyle : React . CSSProperties = {
18- outline : 'none' ,
19- } ;
20-
2110export interface PanelProps extends Omit < IDialogPropTypes , 'getOpenCount' > {
2211 prefixCls : string ;
2312 ariaId ?: string ;
@@ -28,7 +17,6 @@ export interface PanelProps extends Omit<IDialogPropTypes, 'getOpenCount'> {
2817
2918export type PanelRef = {
3019 focus : ( ) => void ;
31- changeActive : ( next : boolean ) => void ;
3220} ;
3321
3422const Panel = React . forwardRef < PanelRef , PanelProps > ( ( props , ref ) => {
@@ -59,23 +47,14 @@ const Panel = React.forwardRef<PanelRef, PanelProps>((props, ref) => {
5947
6048 // ================================= Refs =================================
6149 const { panel : panelRef } = React . useContext ( RefContext ) ;
50+ const internalRef = useRef < HTMLDivElement > ( null ) ;
51+ const mergedRef = useComposeRef ( holderRef , panelRef , internalRef ) ;
6252
63- const mergedRef = useComposeRef ( holderRef , panelRef ) ;
64-
65- const sentinelStartRef = useRef < HTMLDivElement > ( null ) ;
66- const sentinelEndRef = useRef < HTMLDivElement > ( null ) ;
53+ useLockFocus ( visible , ( ) => internalRef . current ) ;
6754
6855 React . useImperativeHandle ( ref , ( ) => ( {
6956 focus : ( ) => {
70- sentinelStartRef . current ?. focus ( { preventScroll : true } ) ;
71- } ,
72- changeActive : ( next ) => {
73- const { activeElement } = document ;
74- if ( next && activeElement === sentinelEndRef . current ) {
75- sentinelStartRef . current . focus ( { preventScroll : true } ) ;
76- } else if ( ! next && activeElement === sentinelStartRef . current ) {
77- sentinelEndRef . current . focus ( { preventScroll : true } ) ;
78- }
57+ internalRef . current ?. focus ( { preventScroll : true } ) ;
7958 } ,
8059 } ) ) ;
8160
@@ -168,13 +147,11 @@ const Panel = React.forwardRef<PanelRef, PanelProps>((props, ref) => {
168147 className = { classNames ( prefixCls , className ) }
169148 onMouseDown = { onMouseDown }
170149 onMouseUp = { onMouseUp }
150+ tabIndex = { - 1 }
171151 >
172- < div ref = { sentinelStartRef } tabIndex = { 0 } style = { entityStyle } >
173- < MemoChildren shouldUpdate = { visible || forceRender } >
174- { modalRender ? modalRender ( content ) : content }
175- </ MemoChildren >
176- </ div >
177- < div tabIndex = { 0 } ref = { sentinelEndRef } style = { sentinelStyle } />
152+ < MemoChildren shouldUpdate = { visible || forceRender } >
153+ { modalRender ? modalRender ( content ) : content }
154+ </ MemoChildren >
178155 </ div >
179156 ) ;
180157} ) ;
0 commit comments