Skip to content

Commit

Permalink
Change toolbar drag remove labels (#25614)
Browse files Browse the repository at this point in the history
* Refactor toolabar drag+remove labels

* fix tests
  • Loading branch information
ntsekouras authored and talldan committed Oct 29, 2020
1 parent eb7f8cc commit e99804f
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 10 deletions.
11 changes: 6 additions & 5 deletions packages/block-editor/src/components/block-mover/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {
import { getBlockType } from '@wordpress/blocks';
import { useState } from '@wordpress/element';
import { withSelect } from '@wordpress/data';
import { __ } from '@wordpress/i18n';
import { _n } from '@wordpress/i18n';

/**
* Internal dependencies
Expand All @@ -44,9 +44,6 @@ function BlockMover( {
return null;
}

const label =
clientIds.length === 1 ? __( 'Drag Block' ) : __( 'Drag Blocks' );

// We emulate a disabled state because forcefully applying the `disabled`
// attribute on the buttons while it has focus causes the screen to change
// to an unfocused state (body as active element) without firing blur on,
Expand All @@ -68,7 +65,11 @@ function BlockMover( {
icon={ dragHandle }
className="block-editor-block-mover__drag-handle"
aria-hidden="true"
label={ label }
label={ _n(
'Drag block',
'Drag blocks',
clientIds.length
) }
// Should not be able to tab to drag handle as this
// button can only be used with a pointer device.
tabIndex="-1"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,8 @@ export function BlockSettingsDropdown( {
shortcut={ shortcuts.remove }
>
{ _n(
'Remove Block',
'Remove Blocks',
'Remove block',
'Remove blocks',
count
) }
</MenuItem>
Expand Down
4 changes: 2 additions & 2 deletions packages/e2e-tests/specs/editor/plugins/cpt-locking.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ describe( 'cpt locking', () => {
);
await clickBlockToolbarButton( 'More options' );
expect(
await page.$x( '//button[contains(text(), "Remove Block")]' )
await page.$x( '//button[contains(text(), "Remove block")]' )
).toHaveLength( 0 );
};

Expand Down Expand Up @@ -172,7 +172,7 @@ describe( 'cpt locking', () => {
);
await clickBlockToolbarButton( 'More options' );
const [ removeBlock ] = await page.$x(
'//button[contains(text(), "Remove Block")]'
'//button[contains(text(), "Remove block")]'
);
await removeBlock.click();
expect( await getEditedPostContent() ).toMatchSnapshot();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ const clickOnBlockSettingsMenuRemoveBlockButton = async () => {
await page.keyboard.press( 'Tab' );

isRemoveButton = await page.evaluate( () => {
return document.activeElement.innerText.includes( 'Remove Block' );
return document.activeElement.innerText.includes( 'Remove block' );
} );

// Stop looping once we find the button
Expand Down

0 comments on commit e99804f

Please sign in to comment.