Skip to content

Commit

Permalink
Tweak remove block label to make it simpler (#49529)
Browse files Browse the repository at this point in the history
* Update block-settings-dropdown.js

* Add check for count

* Update block-deletion.spec.js

* Update tests

* More tests
  • Loading branch information
richtabor authored Apr 7, 2023
1 parent a3faaef commit eb24385
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ import BlockHTMLConvertButton from './block-html-convert-button';
import __unstableBlockSettingsMenuFirstItem from './block-settings-menu-first-item';
import BlockSettingsMenuControls from '../block-settings-menu-controls';
import { store as blockEditorStore } from '../../store';
import useBlockDisplayTitle from '../block-title/use-block-display-title';
import { useShowMoversGestures } from '../block-toolbar/utils';

const noop = () => {};
Expand Down Expand Up @@ -138,11 +137,6 @@ export function BlockSettingsDropdown( {
[ __experimentalSelectBlock ]
);

const blockTitle = useBlockDisplayTitle( {
clientId: firstBlockClientId,
maximumLength: 25,
} );

const updateSelectionAfterRemove = useCallback(
__experimentalSelectBlock
? () => {
Expand Down Expand Up @@ -173,12 +167,8 @@ export function BlockSettingsDropdown( {
]
);

const label = sprintf(
/* translators: %s: block name */
__( 'Remove %s' ),
blockTitle
);
const removeBlockLabel = count === 1 ? label : __( 'Remove blocks' );
const removeBlockLabel =
count === 1 ? __( 'Delete' ) : __( 'Delete blocks' );

// Allows highlighting the parent block outline when focusing or hovering
// the parent block selector within the child.
Expand Down
8 changes: 3 additions & 5 deletions packages/e2e-tests/specs/editor/plugins/cpt-locking.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,7 @@ describe( 'cpt locking', () => {
);
await clickBlockToolbarButton( 'Options' );
expect(
await page.$x(
'//button/span[contains(text(), "Remove Paragraph")]'
)
await page.$x( '//button/span[contains(text(), "Delete")]' )
).toHaveLength( 0 );
};

Expand Down Expand Up @@ -180,7 +178,7 @@ describe( 'cpt locking', () => {
'p1'
);
await clickBlockToolbarButton( 'Options' );
await clickMenuItem( 'Remove Paragraph' );
await clickMenuItem( 'Delete' );
expect( await getEditedPostContent() ).toMatchSnapshot();
} );

Expand All @@ -200,7 +198,7 @@ describe( 'cpt locking', () => {
'p1'
);
await clickBlockToolbarButton( 'Options' );
await clickMenuItem( 'Remove Paragraph' );
await clickMenuItem( 'Delete' );

expect( await getEditedPostContent() ).toMatchSnapshot();
} );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ describe( 'Reusable blocks', () => {
// Delete the block, leaving the reusable block empty.
await clickBlockToolbarButton( 'Options' );
const deleteButton = await page.waitForXPath(
'//button/span[text()="Remove Paragraph"]'
'//button/span[text()="Delete"]'
);
deleteButton.click();

Expand Down
12 changes: 3 additions & 9 deletions test/e2e/specs/editor/various/block-deletion.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,7 @@ test.describe( 'Block deletion', () => {
.getByRole( 'toolbar', { name: 'Block tools' } )
.getByRole( 'button', { name: 'Options' } )
.click();
await page
.getByRole( 'menuitem', { name: 'Remove Paragraph' } )
.click();
await page.getByRole( 'menuitem', { name: 'Delete' } ).click();

// Ensure the last block was removed.
await expect.poll( editor.getBlocks ).toMatchObject( [
Expand Down Expand Up @@ -90,9 +88,7 @@ test.describe( 'Block deletion', () => {
.getByRole( 'toolbar', { name: 'Block tools' } )
.getByRole( 'button', { name: 'Options' } )
.click();
await page
.getByRole( 'menuitem', { name: 'Remove Paragraph' } )
.click();
await page.getByRole( 'menuitem', { name: 'Delete' } ).click();

// Ensure the paragraph was removed.
await expect
Expand Down Expand Up @@ -321,9 +317,7 @@ test.describe( 'Block deletion', () => {
.getByRole( 'toolbar', { name: 'Block tools' } )
.getByRole( 'button', { name: 'Options' } )
.click();
await page
.getByRole( 'menuitem', { name: 'Remove Paragraph' } )
.click();
await page.getByRole( 'menuitem', { name: 'Delete' } ).click();

// Ensure an empty block was created and focused.
await expect(
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/specs/editor/various/block-locking.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ test.describe( 'Block Locking', () => {
await page.click( 'role=button[name="Apply"]' );

await expect(
page.locator( 'role=menuitem[name="Remove Paragraph"]' )
page.locator( 'role=menuitem[name="Delete"]' )
).not.toBeVisible();
} );

Expand Down
8 changes: 3 additions & 5 deletions test/e2e/specs/editor/various/list-view.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,7 @@ test.describe( 'List View', () => {
await listView
.getByRole( 'button', { name: 'Options for Paragraph block' } )
.click();
await page
.getByRole( 'menuitem', { name: /Remove Paragraph/i } )
.click();
await page.getByRole( 'menuitem', { name: /Delete/i } ).click();

// Heading block should be selected as previous block.
await expect(
Expand Down Expand Up @@ -196,7 +194,7 @@ test.describe( 'List View', () => {
await listView
.getByRole( 'button', { name: 'Options for Image block' } )
.click();
await page.getByRole( 'menuitem', { name: /Remove Image/i } ).click();
await page.getByRole( 'menuitem', { name: /Delete/i } ).click();

// Heading block should be selected as previous block.
await expect(
Expand Down Expand Up @@ -247,7 +245,7 @@ test.describe( 'List View', () => {
await listView
.getByRole( 'button', { name: 'Options for Image block' } )
.click();
await page.getByRole( 'menuitem', { name: /Remove blocks/i } ).click();
await page.getByRole( 'menuitem', { name: /Delete blocks/i } ).click();

// Newly created paragraph block should be selected.
await expect(
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/specs/widgets/customizing-widgets.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ test.describe( 'Widgets Customizer', () => {

// Testing removing the block.
await editor.clickBlockToolbarButton( 'Options' );
await page.click( 'role=menuitem[name=/Remove Legacy Widget/]' );
await page.click( 'role=menuitem[name=/Delete/]' );

// Add it back again using the variant.
const testWidgetBlock = await widgetsCustomizerPage.addBlock(
Expand Down

1 comment on commit eb24385

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Flaky tests detected in eb24385.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/4634604531
📝 Reported issues:

Please sign in to comment.