Skip to content

Commit

Permalink
Align rename modals (#62874)
Browse files Browse the repository at this point in the history
Co-authored-by: jameskoster <[email protected]>
Co-authored-by: t-hamano <[email protected]>
Co-authored-by: jasmussen <[email protected]>
Co-authored-by: afercia <[email protected]>
  • Loading branch information
5 people authored Jul 1, 2024
1 parent ae37dc2 commit 214f466
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 13 deletions.
10 changes: 2 additions & 8 deletions packages/block-editor/src/components/block-rename/modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
Modal,
} from '@wordpress/components';
import { __, sprintf } from '@wordpress/i18n';
import { useState, useId } from '@wordpress/element';
import { useState } from '@wordpress/element';
import { speak } from '@wordpress/a11y';

/**
Expand All @@ -27,7 +27,6 @@ export default function BlockRenameModal( {
hasOverridesWarning,
} ) {
const [ editedBlockName, setEditedBlockName ] = useState( blockName );
const descriptionId = useId();

const nameHasChanged = editedBlockName !== blockName;
const nameIsOriginal = editedBlockName === originalBlockName;
Expand Down Expand Up @@ -65,7 +64,6 @@ export default function BlockRenameModal( {
onRequestClose={ onClose }
overlayClassName="block-editor-block-rename-modal"
focusOnMount="firstContentElement"
aria={ { describedby: descriptionId } }
size="small"
>
<form
Expand All @@ -79,16 +77,12 @@ export default function BlockRenameModal( {
handleSubmit();
} }
>
<p id={ descriptionId }>
{ __( 'Enter a custom name for this block.' ) }
</p>
<VStack spacing="3">
<TextControl
__nextHasNoMarginBottom
__next40pxDefaultSize
value={ editedBlockName }
label={ __( 'Block name' ) }
hideLabelFromVision
label={ __( 'Name' ) }
help={
hasOverridesWarning
? __(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ function RenameItemModalContent( { dataviewId, currentTitle, setIsRenaming } ) {
<HStack justify="right">
<Button
variant="tertiary"
__next40pxDefaultSize
onClick={ () => {
setIsRenaming( false );
} }
Expand All @@ -71,8 +72,9 @@ function RenameItemModalContent( { dataviewId, currentTitle, setIsRenaming } ) {
variant="primary"
type="submit"
aria-disabled={ ! title }
__next40pxDefaultSize
>
{ __( 'Rename' ) }
{ __( 'Save' ) }
</Button>
</HStack>
</VStack>
Expand Down Expand Up @@ -160,10 +162,12 @@ function CustomDataViewItem( { dataviewId, isActive } ) {
/>
{ isRenaming && (
<Modal
title={ __( 'Rename view' ) }
title={ __( 'Rename' ) }
onRequestClose={ () => {
setIsRenaming( false );
} }
focusOnMount="firstContentElement"
size="small"
>
<RenameItemModalContent
dataviewId={ dataviewId }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export default function RenameModal( { menuTitle, onClose, onSave } ) {
value={ editedMenuTitle }
placeholder={ __( 'Navigation title' ) }
onChange={ setEditedMenuTitle }
label={ __( 'Name' ) }
/>
<HStack justify="right">
<Button
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/specs/editor/blocks/heading.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ test.describe( 'Heading', () => {
await editor.clickBlockOptionsMenuItem( 'Rename' );
await page
.getByRole( 'dialog', { name: 'Rename' } )
.getByRole( 'textbox', { name: 'Block name' } )
.getByRole( 'textbox', { name: 'Name' } )
.fill( 'My new name' );

await page
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/specs/editor/various/block-renaming.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ test.describe( 'Block Renaming', () => {
await expect( renameModal ).toBeVisible();

const nameInput = renameModal.getByRole( 'textbox', {
name: 'Block name',
name: 'Name',
} );

// Check focus is transferred into the input within the Modal.
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/specs/editor/various/pattern-overrides.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ test.describe( 'Pattern Overrides', () => {
await editor.clickBlockOptionsMenuItem( 'Rename' );
await page
.getByRole( 'dialog', { name: 'Rename' } )
.getByRole( 'textbox', { name: 'Block name' } )
.getByRole( 'textbox', { name: 'Name' } )
.fill( editableParagraphName );
await page
.getByRole( 'dialog', { name: 'Rename' } )
Expand Down

1 comment on commit 214f466

@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 214f466.
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/9742371372
📝 Reported issues:

Please sign in to comment.