@@ -6,6 +6,7 @@ import { ParameterType } from './ParameterType';
6
6
import { ApiComment } from '../ApiComment' ;
7
7
import { LinkDataType , TypeLinkInterface } from './TypeLink' ;
8
8
import references from '@/directory/apiReferences.json' ;
9
+ import { useRef } from 'react' ;
9
10
10
11
interface ApiModalInterface {
11
12
data : any ;
@@ -26,6 +27,7 @@ export const ApiModal = ({
26
27
data = references [ data . target ] ;
27
28
}
28
29
const description = data ?. comment ?. summary ;
30
+ const ref = useRef < HTMLDivElement > ( null ) ;
29
31
30
32
const closeModal = ( ) => {
31
33
clearBC ( ) ;
@@ -84,6 +86,11 @@ export const ApiModal = ({
84
86
} , [ ] as TypeLinkInterface [ ] )
85
87
: [ ] ;
86
88
89
+ if ( showModal ) {
90
+ setTimeout ( ( ) => {
91
+ ref ?. current ?. focus ( ) ;
92
+ } , 0 ) ;
93
+
87
94
if ( typeof window != 'undefined' ) {
88
95
window . onclick = function ( event ) {
89
96
if ( event . target . className . includes ( 'api-modal-container--open' ) ) {
@@ -96,6 +103,8 @@ export const ApiModal = ({
96
103
< View
97
104
aria-label = { `${ name } API Reference` }
98
105
className = { `api-modal-container${ showModal ? ' api-modal-container--open' : '' } ` }
106
+ ref = { ref }
107
+ tabIndex = { 0 }
99
108
>
100
109
< Card as = "dialog" className = "api-modal" aria-modal = "true" >
101
110
< Flex className = "api-model__header" >
@@ -105,6 +114,7 @@ export const ApiModal = ({
105
114
size = "small"
106
115
variation = "link"
107
116
className = "api-modal__close"
117
+ aria-label = "Close"
108
118
>
109
119
< IconX />
110
120
</ Button >
0 commit comments