From e99804faee95f1825a79326bcb48f348a6f0dca2 Mon Sep 17 00:00:00 2001 From: Nik Tsekouras Date: Thu, 24 Sep 2020 16:39:14 +0300 Subject: [PATCH] Change toolbar drag remove labels (#25614) * Refactor toolabar drag+remove labels * fix tests --- .../block-editor/src/components/block-mover/index.js | 11 ++++++----- .../block-settings-menu/block-settings-dropdown.js | 4 ++-- .../specs/editor/plugins/cpt-locking.test.js | 4 ++-- .../specs/editor/various/block-deletion.test.js | 2 +- 4 files changed, 11 insertions(+), 10 deletions(-) diff --git a/packages/block-editor/src/components/block-mover/index.js b/packages/block-editor/src/components/block-mover/index.js index ef84f28916d99a..cf23ed975e40b7 100644 --- a/packages/block-editor/src/components/block-mover/index.js +++ b/packages/block-editor/src/components/block-mover/index.js @@ -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 @@ -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, @@ -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" diff --git a/packages/block-editor/src/components/block-settings-menu/block-settings-dropdown.js b/packages/block-editor/src/components/block-settings-menu/block-settings-dropdown.js index 0bbfc229a30eca..f70e45124265ce 100644 --- a/packages/block-editor/src/components/block-settings-menu/block-settings-dropdown.js +++ b/packages/block-editor/src/components/block-settings-menu/block-settings-dropdown.js @@ -192,8 +192,8 @@ export function BlockSettingsDropdown( { shortcut={ shortcuts.remove } > { _n( - 'Remove Block', - 'Remove Blocks', + 'Remove block', + 'Remove blocks', count ) } diff --git a/packages/e2e-tests/specs/editor/plugins/cpt-locking.test.js b/packages/e2e-tests/specs/editor/plugins/cpt-locking.test.js index 08002328af1ede..e4f62ca47aeb36 100644 --- a/packages/e2e-tests/specs/editor/plugins/cpt-locking.test.js +++ b/packages/e2e-tests/specs/editor/plugins/cpt-locking.test.js @@ -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 ); }; @@ -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(); diff --git a/packages/e2e-tests/specs/editor/various/block-deletion.test.js b/packages/e2e-tests/specs/editor/various/block-deletion.test.js index 56c5496e46151c..60b25677cd4885 100644 --- a/packages/e2e-tests/specs/editor/various/block-deletion.test.js +++ b/packages/e2e-tests/specs/editor/various/block-deletion.test.js @@ -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