diff --git a/packages/block-library/src/button/edit.js b/packages/block-library/src/button/edit.js index d1192014f0b35..fbf2510a06bed 100644 --- a/packages/block-library/src/button/edit.js +++ b/packages/block-library/src/button/edit.js @@ -10,18 +10,24 @@ import { escape } from 'lodash'; import { __ } from '@wordpress/i18n'; import { useCallback, + useEffect, + useState, } from '@wordpress/element'; import { compose, } from '@wordpress/compose'; import { + KeyboardShortcuts, PanelBody, RangeControl, TextControl, ToggleControl, withFallbackStyles, + ToolbarButton, + ToolbarGroup, } from '@wordpress/components'; import { + BlockControls, __experimentalUseGradient, ContrastChecker, InspectorControls, @@ -37,6 +43,8 @@ import { DOWN, BACKSPACE, ENTER, + rawShortcut, + displayShortcut, } from '@wordpress/keycodes'; const { getComputedStyle } = window; @@ -94,7 +102,19 @@ const handleLinkControlOnKeyPress = ( event ) => { }; function URLPicker( { isSelected, url, title, setAttributes, opensInNewTab, onToggleOpenInNewTab } ) { - return isSelected ? ( + const [ isURLPickerOpen, setIsURLPickerOpen ] = useState( false ); + useEffect( + () => { + if ( ! isSelected ) { + setIsURLPickerOpen( false ); + } + }, + [ isSelected ] + ); + const openLinkControl = () => { + setIsURLPickerOpen( true ); + }; + const linkControl = isURLPickerOpen && ( { + setIsURLPickerOpen( false ); + } } /> - ) : null; + ); + return ( + <> + + + + + + + { linkControl } + + ); } function ButtonEdit( {