Skip to content

Commit

Permalink
Adding the label to the interactive element
Browse files Browse the repository at this point in the history
  • Loading branch information
ramonjd committed Apr 21, 2023
1 parent 91622db commit 53903e4
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
19 changes: 14 additions & 5 deletions packages/edit-site/src/components/editor-canvas-container/index.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
/**
* WordPress dependencies
*/
import { Children, cloneElement, useState } from '@wordpress/element';
import { Children, cloneElement, useState, useMemo } from '@wordpress/element';
import { createSlotFill, Button } from '@wordpress/components';
import { ESCAPE } from '@wordpress/keycodes';
import { __ } from '@wordpress/i18n';
import { useDispatch } from '@wordpress/data';
import { useDispatch, useSelect } from '@wordpress/data';
import { closeSmall } from '@wordpress/icons';
import { useFocusOnMount, useFocusReturn } from '@wordpress/compose';

Expand All @@ -25,7 +25,7 @@ import { store as editSiteStore } from '../../store';
export function getEditorCanvasContainerTitle( view ) {
switch ( view ) {
case 'style-book':
return __( 'Style book' );
return __( 'Style Book' );
default:
return '';
}
Expand All @@ -40,13 +40,21 @@ function EditorCanvasContainer( {
closeButtonLabel,
onClose = () => {},
} ) {
const editorCanvasContainerView = useSelect(
( select ) =>
unlock( select( editSiteStore ) ).getEditorCanvasContainerView(),
[]
);
const [ isClosed, setIsClosed ] = useState( false );
const { setEditorCanvasContainerView } = unlock(
useDispatch( editSiteStore )
);
const focusOnMountRef = useFocusOnMount( 'firstElement' );
const sectionFocusReturnRef = useFocusReturn();

const title = useMemo(
() => getEditorCanvasContainerTitle( editorCanvasContainerView ),
[ editorCanvasContainerView ]
);
function onCloseContainer() {
onClose();
setEditorCanvasContainerView( 'init' );
Expand Down Expand Up @@ -78,11 +86,12 @@ function EditorCanvasContainer( {

return (
<EditorCanvasContainerFill>
{ /* eslint-disable-next-line jsx-a11y/no-static-element-interactions */ }
{ /* eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions */ }
<section
className="edit-site-editor-canvas-container"
ref={ focusOnMountRef }
onKeyDown={ closeOnEscape }
aria-label={ title }
>
<Button
className="edit-site-editor-canvas-container__close-button"
Expand Down
1 change: 0 additions & 1 deletion packages/edit-site/src/components/style-book/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,6 @@ function StyleBook( { isSelected, onSelect } ) {
color: textColor,
background: backgroundColor,
} }
aria-label={ __( 'Style Book' ) }
>
{ resizeObserver }
<TabPanel
Expand Down

0 comments on commit 53903e4

Please sign in to comment.