Skip to content

Commit

Permalink
Fix speaking on multi selection
Browse files Browse the repository at this point in the history
  • Loading branch information
adamziel committed Nov 27, 2020
1 parent ba371bc commit ebc5b7d
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1175,10 +1175,6 @@ _Parameters_
- _start_ `string`: First block of the multi selection.
- _end_ `string`: Last block of the multiselection.

_Returns_

- `Object`: Action object.

<a name="receiveBlocks" href="#receiveBlocks">#</a> **receiveBlocks**

Returns an action object used in signalling that blocks have been received.
Expand Down Expand Up @@ -1401,6 +1397,10 @@ _Returns_

Returns an action object used in signalling that a block multi-selection has started.

_Returns_

- `Object`: Action object.

<a name="startTyping" href="#startTyping">#</a> **startTyping**

Returns an action object used in signalling that the user has begun to type.
Expand Down
40 changes: 20 additions & 20 deletions packages/block-editor/src/store/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -232,25 +232,13 @@ export function* selectNextBlock( clientId ) {

/**
* Returns an action object used in signalling that a block multi-selection has started.
*
* @return {Object} Action object.
*/
export function* startMultiSelect() {
yield {
export function startMultiSelect() {
return {
type: 'START_MULTI_SELECT',
};

const blockCount = yield controls.select(
'core/block-editor',
'getSelectedBlockCount'
);

speak(
sprintf(
/* translators: %s: number of selected blocks */
_n( '%s block selected.', '%s blocks selected.', blockCount ),
blockCount
),
'assertive'
);
}

/**
Expand All @@ -269,15 +257,27 @@ export function stopMultiSelect() {
*
* @param {string} start First block of the multi selection.
* @param {string} end Last block of the multiselection.
*
* @return {Object} Action object.
*/
export function multiSelect( start, end ) {
return {
export function* multiSelect( start, end ) {
yield {
type: 'MULTI_SELECT',
start,
end,
};

const blockCount = yield controls.select(
'core/block-editor',
'getSelectedBlockCount'
);

speak(
sprintf(
/* translators: %s: number of selected blocks */
_n( '%s block selected.', '%s blocks selected.', blockCount ),
blockCount
),
'assertive'
);
}

/**
Expand Down
6 changes: 3 additions & 3 deletions packages/block-editor/src/store/test/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,7 @@ describe( 'actions', () => {

describe( 'startMultiSelect', () => {
it( 'should return the START_MULTI_SELECT', () => {
const fulfillment = startMultiSelect();
expect( fulfillment.next().value ).toEqual( {
expect( startMultiSelect() ).toEqual( {
type: 'START_MULTI_SELECT',
} );
} );
Expand All @@ -120,7 +119,8 @@ describe( 'actions', () => {
it( 'should return MULTI_SELECT action', () => {
const start = 'start';
const end = 'end';
expect( multiSelect( start, end ) ).toEqual( {
const fulfillment = multiSelect( start, end );
expect( fulfillment.next().value ).toEqual( {
type: 'MULTI_SELECT',
start,
end,
Expand Down

0 comments on commit ebc5b7d

Please sign in to comment.