Skip to content

Commit

Permalink
Navigation Block: Fix issue with double-clicking "Create a new menu" …
Browse files Browse the repository at this point in the history
…causing duplicate menus. (#67488)

Co-authored-by: creador-dev <[email protected]>
Co-authored-by: talldan <[email protected]>
  • Loading branch information
3 people authored Dec 3, 2024
1 parent 6ef2f24 commit 680fef5
Showing 1 changed file with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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. <button>Create a new Menu?</button>'
Expand All @@ -15,8 +22,10 @@ function DeletedNavigationWarning( { onCreateNew, isNotice = false } ) {
button: (
<Button
__next40pxDefaultSize
onClick={ onCreateNew }
onClick={ handleButtonClick }
variant="link"
disabled={ isButtonDisabled }
accessibleWhenDisabled
/>
),
}
Expand Down

0 comments on commit 680fef5

Please sign in to comment.