diff --git a/packages/fields/src/components/create-template-part-modal/index.tsx b/packages/fields/src/components/create-template-part-modal/index.tsx index 40fdb9f216696..578173ceb05c3 100644 --- a/packages/fields/src/components/create-template-part-modal/index.tsx +++ b/packages/fields/src/components/create-template-part-modal/index.tsx @@ -5,17 +5,11 @@ import { Icon, BaseControl, TextControl, - Flex, - FlexItem, - FlexBlock, Button, Modal, - __experimentalRadioGroup as RadioGroup, - __experimentalRadio as Radio, __experimentalHStack as HStack, __experimentalVStack as VStack, } from '@wordpress/components'; -import { useInstanceId } from '@wordpress/compose'; import { store as coreStore } from '@wordpress/core-data'; import { useDispatch, useSelect } from '@wordpress/data'; import { useState } from '@wordpress/element'; @@ -40,6 +34,13 @@ import { useExistingTemplateParts, } from './utils'; +function getAreaRadioId( value: string ) { + return `fields-create-template-part-modal__area-option-${ value }`; +} +function getAreaRadioDescriptionId( value: string ) { + return `fields-create-template-part-modal__area-option-description-${ value }`; +} + type CreateTemplatePartModalContentsProps = { defaultArea?: string; blocks: any[]; @@ -122,7 +123,6 @@ export function CreateTemplatePartModalContents( { const [ title, setTitle ] = useState( defaultTitle ); const [ area, setArea ] = useState( defaultArea ); const [ isSubmitting, setIsSubmitting ] = useState( false ); - const instanceId = useInstanceId( CreateTemplatePartModal ); const defaultTemplatePartAreas = useSelect( ( select ) => { const areas = @@ -202,51 +202,60 @@ export function CreateTemplatePartModalContents( { onChange={ setTitle } required /> - - - value && typeof value === 'string' - ? setArea( value ) - : () => void 0 - } - checked={ area } +
+ + { __( 'Area' ) } + +
{ defaultTemplatePartAreas.map( ( { icon, label, area: value, description } ) => ( - - - - - - - { label } -
{ description }
-
- - - { area === value && ( - - ) } - -
-
+ { + setArea( value ); + } } + aria-describedby={ getAreaRadioDescriptionId( + value + ) } + /> + + + +

+ { description } +

+
) ) } - - + +