@@ -10,6 +10,7 @@ import { camelCase } from "lodash-es";
1010import { ModalProvider } from "../context/ModalContext" ;
1111import { ModalContextProps } from "../context/ModalContext.types" ;
1212import useKeyEvent from "../../../hooks/useKeyEvent" ;
13+ import { keyCodes } from "../../../constants" ;
1314
1415const Modal = forwardRef (
1516 (
@@ -27,8 +28,8 @@ const Modal = forwardRef(
2728 } : ModalProps ,
2829 ref : React . ForwardedRef < HTMLDivElement >
2930 ) => {
30- const [ titleId , setTitleId ] = useState < string > ( "" ) ;
31- const [ descriptionId , setDescriptionId ] = useState < string > ( "" ) ;
31+ const [ titleId , setTitleId ] = useState < string > ( ) ;
32+ const [ descriptionId , setDescriptionId ] = useState < string > ( ) ;
3233
3334 const setTitleIdCallback = useCallback ( ( id : string ) => setTitleId ( id ) , [ ] ) ;
3435 const setDescriptionIdCallback = useCallback ( ( id : string ) => setDescriptionId ( id ) , [ ] ) ;
@@ -61,7 +62,7 @@ const Modal = forwardRef(
6162 useKeyEvent ( {
6263 callback : onEscClick ,
6364 capture : true ,
64- keys : [ "Escape" ]
65+ keys : [ keyCodes . ESCAPE ]
6566 } ) ;
6667
6768 if ( ! show ) {
@@ -83,8 +84,8 @@ const Modal = forwardRef(
8384 data-testid = { dataTestId || getTestId ( ComponentDefaultTestId . MODAL_NEXT , id ) }
8485 role = "dialog"
8586 aria-modal
86- aria-labelledby = { titleId || undefined }
87- aria-describedby = { descriptionId || undefined }
87+ aria-labelledby = { titleId }
88+ aria-describedby = { descriptionId }
8889 >
8990 < ModalTopActions
9091 renderAction = { renderHeaderAction }
0 commit comments