Skip to content

Commit

Permalink
Sidebar Navigation: Refactoring the delete modal with ConfirmDialog (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
t-hamano authored Jun 26, 2023
1 parent 67b5ebe commit e252453
Showing 1 changed file with 14 additions and 35 deletions.
Original file line number Diff line number Diff line change
@@ -1,45 +1,24 @@
/**
* WordPress dependencies
*/
import {
__experimentalHStack as HStack,
__experimentalVStack as VStack,
Button,
Modal,
} from '@wordpress/components';
import { __experimentalConfirmDialog as ConfirmDialog } from '@wordpress/components';
import { __ } from '@wordpress/i18n';

export default function RenameModal( { onClose, onConfirm } ) {
return (
<Modal title={ __( 'Delete' ) } onRequestClose={ onClose }>
<form>
<VStack spacing="3">
<p>
{ __(
'Are you sure you want to delete this Navigation menu?'
) }
</p>
<HStack justify="right">
<Button variant="tertiary" onClick={ onClose }>
{ __( 'Cancel' ) }
</Button>
<ConfirmDialog
isOpen={ true }
onConfirm={ ( e ) => {
e.preventDefault();
onConfirm();

<Button
variant="primary"
type="submit"
onClick={ ( e ) => {
e.preventDefault();
onConfirm();

// Immediate close avoids ability to hit delete multiple times.
onClose();
} }
>
{ __( 'Delete' ) }
</Button>
</HStack>
</VStack>
</form>
</Modal>
// Immediate close avoids ability to hit delete multiple times.
onClose();
} }
onCancel={ onClose }
confirmButtonText={ __( 'Delete' ) }
>
{ __( 'Are you sure you want to delete this Navigation menu?' ) }
</ConfirmDialog>
);
}

0 comments on commit e252453

Please sign in to comment.