Skip to content

Commit fe8c989

Browse files
creador-devcreador-devtalldan
authored andcommitted
Navigation Block: Fix issue with double-clicking "Create a new menu" causing duplicate menus. (#67488)
Co-authored-by: creador-dev <creadordev@git.wordpress.org> Co-authored-by: talldan <talldanwp@git.wordpress.org>
1 parent a90a440 commit fe8c989

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

‎packages/block-library/src/navigation/edit/deleted-navigation-warning.js‎

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,16 @@
44
import { Warning } from '@wordpress/block-editor';
55
import { Button, Notice } from '@wordpress/components';
66
import { __ } from '@wordpress/i18n';
7-
import { createInterpolateElement } from '@wordpress/element';
7+
import { useState, createInterpolateElement } from '@wordpress/element';
88

99
function DeletedNavigationWarning( { onCreateNew, isNotice = false } ) {
10+
const [ isButtonDisabled, setIsButtonDisabled ] = useState( false );
11+
12+
const handleButtonClick = () => {
13+
setIsButtonDisabled( true );
14+
onCreateNew();
15+
};
16+
1017
const message = createInterpolateElement(
1118
__(
1219
'Navigation Menu has been deleted or is unavailable. <button>Create a new Menu?</button>'
@@ -15,8 +22,10 @@ function DeletedNavigationWarning( { onCreateNew, isNotice = false } ) {
1522
button: (
1623
<Button
1724
__next40pxDefaultSize
18-
onClick={ onCreateNew }
25+
onClick={ handleButtonClick }
1926
variant="link"
27+
disabled={ isButtonDisabled }
28+
accessibleWhenDisabled
2029
/>
2130
),
2231
}

0 commit comments

Comments
 (0)