Skip to content

Commit

Permalink
Fix and simplify the Modal dialog close button label (#47540)
Browse files Browse the repository at this point in the history
* Simplify Modal close button label.

* Adjust tsts and update snapshots.
  • Loading branch information
afercia authored Jan 30, 2023
1 parent 15cc592 commit 6304e5d
Show file tree
Hide file tree
Showing 22 changed files with 8 additions and 25 deletions.
1 change: 0 additions & 1 deletion packages/block-editor/src/components/block-lock/modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ export default function BlockLockModal( { clientId, onClose } ) {
blockInformation.title
) }
overlayClassName="block-editor-block-lock-modal"
closeLabel={ __( 'Close' ) }
onRequestClose={ onClose }
>
<p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ function PatternsExplorerModal( { onModalClose, ...restProps } ) {
return (
<Modal
title={ __( 'Patterns' ) }
closeLabel={ __( 'Close' ) }
onRequestClose={ onModalClose }
isFullScreen
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ export default function NavigationMenuDeleteControl( { onDelete } ) {
__( 'Delete %s' ),
title
) }
closeLabel={ __( 'Cancel' ) }
onRequestClose={ () => setIsConfirmModalVisible( false ) }
>
<p>
Expand Down
1 change: 0 additions & 1 deletion packages/block-library/src/page-list/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,6 @@ function ConvertToLinksModal( { onClick, disabled } ) {
</BlockControls>
{ isOpen && (
<Modal
closeLabel={ __( 'Close' ) }
onRequestClose={ closeModal }
title={ __( 'Customize this menu' ) }
className={ 'wp-block-page-list-modal' }
Expand Down
1 change: 0 additions & 1 deletion packages/block-library/src/query/edit/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ function PatternSelectionModal( {
<Modal
className="block-editor-query-pattern__selection-modal"
title={ __( 'Choose a pattern' ) }
closeLabel={ __( 'Cancel' ) }
onRequestClose={ () => setIsPatternSelectionModalOpen( false ) }
>
<BlockContextProvider value={ blockPreviewContext }>
Expand Down
1 change: 0 additions & 1 deletion packages/block-library/src/template-part/edit/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,6 @@ export default function TemplatePartEdit( {
__( 'Choose a %s' ),
areaObject.label.toLowerCase()
) }
closeLabel={ __( 'Cancel' ) }
onRequestClose={ () =>
setIsTemplatePartSelectionOpen( false )
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ export default function TitleModal( { areaLabel, onClose, onSubmit } ) {
__( 'Name and create your new %s' ),
areaLabel.toLowerCase()
) }
closeLabel={ __( 'Cancel' ) }
overlayClassName="wp-block-template-part__placeholder-create-new__title-form"
onRequestClose={ onClose }
>
Expand Down
3 changes: 1 addition & 2 deletions packages/components/src/modal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -202,8 +202,7 @@ function UnforwardedModal(
onClick={ onRequestClose }
icon={ close }
label={
closeButtonLabel ||
__( 'Close dialog' )
closeButtonLabel || __( 'Close' )
}
/>
) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@ export default function KeyboardShortcutHelpModal( {
<Modal
className="customize-widgets-keyboard-shortcut-help-modal"
title={ __( 'Keyboard shortcuts' ) }
closeLabel={ __( 'Close' ) }
onRequestClose={ toggleModal }
>
<ShortcutSection
Expand Down
4 changes: 2 additions & 2 deletions packages/e2e-tests/specs/editor/various/nux.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ describe( 'New User Experience (NUX)', () => {
expect( welcomeGuide ).not.toBeNull();

// Close the guide
await page.click( 'button[aria-label="Close dialog"]' );
await page.click( '[role="dialog"] button[aria-label="Close"]' );

// Reload the editor.
await page.reload();
Expand All @@ -125,7 +125,7 @@ describe( 'New User Experience (NUX)', () => {
expect( welcomeGuide ).not.toBeNull();

// Close the guide.
await page.click( 'button[aria-label="Close dialog"]' );
await page.click( '[role="dialog"] button[aria-label="Close"]' );

// Focus should be in post title field.
const postTitle = await page.waitForSelector(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ exports[`EditPostPreferencesModal should match snapshot when the modal is active
</h1>
</div>
<button
aria-label="Close dialog"
aria-label="Close"
class="components-button has-icon"
type="button"
>
Expand Down Expand Up @@ -703,7 +703,7 @@ exports[`EditPostPreferencesModal should match snapshot when the modal is active
</h1>
</div>
<button
aria-label="Close dialog"
aria-label="Close"
class="components-button has-icon"
type="button"
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ export default function PostTemplateCreateModal( { onClose } ) {
return (
<Modal
title={ __( 'Create custom template' ) }
closeLabel={ __( 'Close' ) }
onRequestClose={ cancel }
className="edit-post-post-template__create-modal"
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,6 @@ export default function StartPageOptions() {
<Modal
className="edit-post-start-page-options__modal"
title={ __( 'Choose a pattern' ) }
closeLabel={ __( 'Cancel' ) }
onRequestClose={ () => {
setModalState( START_PAGE_MODAL_STATES.CLOSED );
} }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ function AddCustomGenericTemplateModal( {
return (
<Modal
title={ __( 'Create custom template' ) }
closeLabel={ __( 'Close' ) }
onRequestClose={ () => {
onClose();
} }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,6 @@ function AddCustomTemplateModal( {
entityForSuggestions.labels.singular_name
) }
className={ baseCssClass }
closeLabel={ __( 'Close' ) }
onRequestClose={ onClose }
>
{ isCreatingTemplate && <TemplateActionsLoadingScreen /> }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ export default function CreateTemplatePartModal( { closeModal, onCreate } ) {
return (
<Modal
title={ __( 'Create a template part' ) }
closeLabel={ __( 'Close' ) }
onRequestClose={ closeModal }
overlayClassName="edit-site-create-template-part-modal"
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ export default function KeyboardShortcutHelpModal( {
<Modal
className="edit-site-keyboard-shortcut-help-modal"
title={ __( 'Keyboard shortcuts' ) }
closeLabel={ __( 'Close' ) }
onRequestClose={ toggleModal }
>
<ShortcutSection
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ export default function RenameMenuItem( { template, onClose } ) {
{ isModalOpen && (
<Modal
title={ __( 'Rename' ) }
closeLabel={ __( 'Close' ) }
onRequestClose={ () => {
setIsModalOpen( false );
} }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ export default function KeyboardShortcutHelpModal( {
<Modal
className="edit-widgets-keyboard-shortcut-help-modal"
title={ __( 'Keyboard shortcuts' ) }
closeLabel={ __( 'Close' ) }
onRequestClose={ toggleModal }
>
<ShortcutSection
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ export default function PreferencesModal( { closeModal, children } ) {
<Modal
className="interface-preferences-modal"
title={ __( 'Preferences' ) }
closeLabel={ __( 'Close' ) }
onRequestClose={ closeModal }
>
{ children }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,6 @@ export default function ReusableBlockConvertButton( {
{ isModalOpen && (
<Modal
title={ __( 'Create Reusable block' ) }
closeLabel={ __( 'Close' ) }
onRequestClose={ () => {
setIsModalOpen( false );
setTitle( '' );
Expand Down
4 changes: 3 additions & 1 deletion test/e2e/specs/editor/various/preview.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,8 @@ class PreviewUtils {
return;
}

await this.page.click( 'role=button[name="Close dialog"i]' );
await this.page.click(
'role=dialog[name="Preferences"i] >> role=button[name="Close"i]'
);
}
}

0 comments on commit 6304e5d

Please sign in to comment.