Skip to content

Commit

Permalink
Add speak call, use clearSelectedBlock action
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewserong committed Mar 5, 2023
1 parent 6f79d50 commit f464168
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {
import { useDispatch, useSelect } from '@wordpress/data';
import { focus } from '@wordpress/dom';
import { useRef, useState } from '@wordpress/element';
import { speak } from '@wordpress/a11y';
import { __ } from '@wordpress/i18n';
import { closeSmall } from '@wordpress/icons';
import { useShortcut } from '@wordpress/keyboard-shortcuts';
Expand All @@ -32,7 +33,7 @@ import ListViewOutline from './list-view-outline';

export default function ListViewSidebar() {
const { setIsListViewOpened } = useDispatch( editPostStore );
const { selectBlock } = useDispatch( blockEditorStore );
const { clearSelectedBlock } = useDispatch( blockEditorStore );
const { hasBlockSelection } = useSelect(
( select ) => ( {
hasBlockSelection:
Expand All @@ -57,7 +58,8 @@ export default function ListViewSidebar() {
hasBlockSelection
) {
event.preventDefault();
selectBlock();
clearSelectedBlock();
speak( __( 'All blocks deselected.' ), 'assertive' );
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
useMergeRefs,
} from '@wordpress/compose';
import { useDispatch, useSelect } from '@wordpress/data';
import { speak } from '@wordpress/a11y';
import { __ } from '@wordpress/i18n';
import { closeSmall } from '@wordpress/icons';
import { ESCAPE } from '@wordpress/keycodes';
Expand All @@ -24,7 +25,7 @@ import { store as editSiteStore } from '../../store';

export default function ListViewSidebar() {
const { setIsListViewOpened } = useDispatch( editSiteStore );
const { selectBlock } = useDispatch( blockEditorStore );
const { clearSelectedBlock } = useDispatch( blockEditorStore );
const { hasBlockSelection } = useSelect(
( select ) => ( {
hasBlockSelection:
Expand All @@ -46,7 +47,8 @@ export default function ListViewSidebar() {
hasBlockSelection
) {
event.preventDefault();
selectBlock();
clearSelectedBlock();
speak( __( 'All blocks deselected.' ), 'assertive' );
return;
}

Expand Down

0 comments on commit f464168

Please sign in to comment.