Skip to content

Commit 73bbe9a

Browse files
committed
fix focus
1 parent 2aeb37c commit 73bbe9a

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

packages/js/src/ai-content-planner/components/content-suggestions-modal.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { UsageCounter } from "@yoast/ai-frontend";
66
import { BookOpenIcon, StarIcon, MapIcon } from "@heroicons/react/outline";
77
import { noop } from "lodash";
88
import classNames from "classnames";
9-
import { Fragment } from "@wordpress/element";
9+
import { Fragment, useRef, useEffect } from "@wordpress/element";
1010
import { Transition } from "@headlessui/react";
1111

1212
const intentBadge = {
@@ -118,6 +118,13 @@ const LoadingModalContent = () => {
118118
*/
119119
export 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

Comments
 (0)