File tree 1 file changed +12
-0
lines changed
packages/orbit-components/src/Dialog
1 file changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -13,6 +13,7 @@ import useLockScrolling from "../hooks/useLockScrolling";
13
13
import useClickOutside from "../hooks/useClickOutside" ;
14
14
import useRandomId from "../hooks/useRandomId" ;
15
15
import type { Props } from "./types" ;
16
+ import FOCUSABLE_ELEMENT_SELECTORS from "../hooks/useFocusTrap/consts" ;
16
17
17
18
const ActionButtonWrapper = ( { children } : { children : React . ReactNode } ) => {
18
19
return (
@@ -72,6 +73,17 @@ const Dialog = ({
72
73
} ;
73
74
} , [ triggerRef ] ) ;
74
75
76
+ React . useEffect ( ( ) => {
77
+ if ( ref . current ) {
78
+ const focusableElements = ref . current . querySelectorAll < HTMLElement > (
79
+ FOCUSABLE_ELEMENT_SELECTORS ,
80
+ ) ;
81
+ if ( focusableElements . length > 0 ) {
82
+ focusableElements [ 0 ] . focus ( ) ;
83
+ }
84
+ }
85
+ } , [ ] ) ;
86
+
75
87
const handleClose = ( ev : MouseEvent ) => {
76
88
if ( ref && ref . current && onClose ) {
77
89
if ( ref . current && ! ref . current . contains ( ev . target as Node ) ) onClose ( ) ;
You can’t perform that action at this time.
0 commit comments