Skip to content
This repository has been archived by the owner on Feb 23, 2024. It is now read-only.

Commit

Permalink
Add label for Block Title component to satisfy accessibility (#4585)
Browse files Browse the repository at this point in the history
  • Loading branch information
tjcafferkey committed Aug 17, 2021
1 parent 167ee30 commit 0942e0d
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions assets/js/editor-components/block-title/index.js
Expand Up @@ -4,17 +4,29 @@
import PropTypes from 'prop-types';
import { PlainText } from '@wordpress/block-editor';
import classnames from 'classnames';
import { withInstanceId } from '@wordpress/compose';
import { __ } from '@wordpress/i18n';

/**
* Internal dependencies
*/
import './editor.scss';

const BlockTitle = ( { className, headingLevel, onChange, heading } ) => {
const BlockTitle = ( {
className,
headingLevel,
onChange,
heading,
instanceId,
} ) => {
const TagName = `h${ headingLevel }`;
return (
<TagName>
<label className="screen-reader-text" htmlFor={ `block-title-${ instanceId }` }>
{ __( 'Block title', 'woo-gutenberg-products-block' ) }
</label>
<PlainText
id={ `block-title-${ instanceId }` }
className={ classnames(
'wc-block-editor-components-title',
className
Expand Down Expand Up @@ -45,4 +57,4 @@ BlockTitle.propTypes = {
headingLevel: PropTypes.number,
};

export default BlockTitle;
export default withInstanceId( BlockTitle );

0 comments on commit 0942e0d

Please sign in to comment.