@@ -6,7 +6,7 @@ import { UsageCounter } from "@yoast/ai-frontend";
66import { BookOpenIcon , StarIcon , MapIcon } from "@heroicons/react/outline" ;
77import { noop } from "lodash" ;
88import classNames from "classnames" ;
9- import { Fragment } from "@wordpress/element" ;
9+ import { Fragment , useRef , useEffect } from "@wordpress/element" ;
1010import { Transition } from "@headlessui/react" ;
1111
1212const intentBadge = {
@@ -118,6 +118,13 @@ const LoadingModalContent = () => {
118118 */
119119export const ContentSuggestionsModal = ( { status, isPremium } ) => {
120120 const svgAriaProps = useSvgAria ( ) ;
121+ const closeButtonRef = useRef ( null ) ;
122+
123+ useEffect ( ( ) => {
124+ if ( status === "content-suggestions-loading" ) {
125+ closeButtonRef . current ?. focus ( ) ;
126+ }
127+ } , [ status ] ) ;
121128 const suggestions = [
122129 {
123130 intent : "informational" ,
@@ -153,7 +160,9 @@ export const ContentSuggestionsModal = ( { status, isPremium } ) => {
153160
154161 return (
155162 < Modal . Panel
156- className = "yst-p-0 yst-max-w-2xl" closeButtonScreenReaderText = { __ ( "Close content suggestions modal" , "wordpress-seo" ) }
163+ className = "yst-p-0 yst-max-w-2xl"
164+ closeButtonScreenReaderText = { __ ( "Close content suggestions modal" , "wordpress-seo" ) }
165+ closeButtonRef = { closeButtonRef }
157166 >
158167 < Modal . Container >
159168 < Modal . Container . Header className = "yst-flex yst-items-center yst-gap-2 yst-pe-12 yst-py-6 yst-ps-6 yst-border-b yst-border-slate-200" >
0 commit comments