From 680fef531408601dcd04e199aefdfac7190cb577 Mon Sep 17 00:00:00 2001 From: Pawan Kumar Date: Tue, 3 Dec 2024 11:33:01 +0530 Subject: [PATCH] Navigation Block: Fix issue with double-clicking "Create a new menu" causing duplicate menus. (#67488) Co-authored-by: creador-dev Co-authored-by: talldan --- .../navigation/edit/deleted-navigation-warning.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/packages/block-library/src/navigation/edit/deleted-navigation-warning.js b/packages/block-library/src/navigation/edit/deleted-navigation-warning.js index 22d1e339c5c004..3d40f4d031ed34 100644 --- a/packages/block-library/src/navigation/edit/deleted-navigation-warning.js +++ b/packages/block-library/src/navigation/edit/deleted-navigation-warning.js @@ -4,9 +4,16 @@ import { Warning } from '@wordpress/block-editor'; import { Button, Notice } from '@wordpress/components'; import { __ } from '@wordpress/i18n'; -import { createInterpolateElement } from '@wordpress/element'; +import { useState, createInterpolateElement } from '@wordpress/element'; function DeletedNavigationWarning( { onCreateNew, isNotice = false } ) { + const [ isButtonDisabled, setIsButtonDisabled ] = useState( false ); + + const handleButtonClick = () => { + setIsButtonDisabled( true ); + onCreateNew(); + }; + const message = createInterpolateElement( __( 'Navigation Menu has been deleted or is unavailable. ' @@ -15,8 +22,10 @@ function DeletedNavigationWarning( { onCreateNew, isNotice = false } ) { button: (