File tree Expand file tree Collapse file tree 4 files changed +13
-10
lines changed
src/components/overlays/Dialog Expand file tree Collapse file tree 4 files changed +13
-10
lines changed Original file line number Diff line number Diff line change @@ -150,11 +150,7 @@ export const Dialog = forwardRef(function Dialog(
150150 } , [ props , ref ] ) ;
151151
152152 return (
153- < FocusScope
154- restoreFocus
155- autoFocus = { isEntered }
156- contain = { isEntered && context . type !== 'panel' }
157- >
153+ < FocusScope restoreFocus contain = { isEntered && context . type !== 'panel' } >
158154 { content }
159155 </ FocusScope >
160156 ) ;
@@ -202,11 +198,15 @@ const DialogContent = forwardRef(function DialogContent(
202198
203199 // Focus the first focusable element in the dialog when it opens
204200 useEffect ( ( ) => {
205- setTimeout ( ( ) => {
206- focusManager ?. focusFirst ( ) ;
207- setIsCloseDisabled ( false ) ;
208- } ) ;
209- } , [ ] ) ;
201+ if ( contextProps . isOpen ) {
202+ setTimeout ( ( ) => {
203+ focusManager ?. focusFirst ( ) ;
204+ setIsCloseDisabled ( false ) ;
205+ } ) ;
206+ } else {
207+ setIsCloseDisabled ( true ) ;
208+ }
209+ } , [ contextProps . isOpen ] ) ;
210210
211211 // let hasHeader = useHasChild('[data-id="Header"]', domRef);
212212 // let hasFooter = useHasChild('[data-id="Footer"]', domRef);
Original file line number Diff line number Diff line change @@ -64,6 +64,7 @@ export function DialogContainer(props: CubeDialogContainerProps) {
6464 type,
6565 onClose : onDismiss ,
6666 isDismissable,
67+ isOpen,
6768 } ;
6869
6970 return (
Original file line number Diff line number Diff line change @@ -309,6 +309,7 @@ function DialogTriggerBase(props) {
309309 type,
310310 onClose,
311311 isDismissable,
312+ isOpen : state . isOpen ,
312313 ...dialogProps ,
313314 } ;
314315
Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ export interface DialogContextValue extends HTMLAttributes<HTMLElement> {
1111 | 'panel' ;
1212 isDismissable ?: boolean ;
1313 onClose ?: ( arg ?: string ) => void ;
14+ isOpen ?: boolean ;
1415}
1516
1617export const DialogContext = createContext < DialogContextValue | null > ( { } ) ;
You can’t perform that action at this time.
0 commit comments