Skip to content

Commit

Permalink
Avoid deleting the block when pressing delete key one too many times …
Browse files Browse the repository at this point in the history
…in URLPopover
  • Loading branch information
talldan committed May 3, 2024
1 parent 9bf67c4 commit 9ec1c11
Showing 1 changed file with 0 additions and 20 deletions.
20 changes: 0 additions & 20 deletions packages/block-library/src/social-link/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,11 @@ import classNames from 'classnames';
/**
* WordPress dependencies
*/
import { DELETE, BACKSPACE } from '@wordpress/keycodes';
import { useDispatch } from '@wordpress/data';

import {
InspectorControls,
URLPopover,
URLInput,
useBlockProps,
store as blockEditorStore,
} from '@wordpress/block-editor';
import { useState } from '@wordpress/element';
import {
Expand All @@ -36,9 +32,7 @@ const SocialLinkURLPopover = ( {
setAttributes,
setPopover,
popoverAnchor,
clientId,
} ) => {
const { removeBlock } = useDispatch( blockEditorStore );
return (
<URLPopover
anchor={ popoverAnchor }
Expand All @@ -62,18 +56,6 @@ const SocialLinkURLPopover = ( {
label={ __( 'Enter social link' ) }
hideLabelFromVision
disableSuggestions
onKeyDown={ ( event ) => {
if (
!! url ||
event.defaultPrevented ||
! [ BACKSPACE, DELETE ].includes(
event.keyCode
)
) {
return;
}
removeBlock( clientId );
} }
/>
</div>
<Button
Expand All @@ -91,7 +73,6 @@ const SocialLinkEdit = ( {
context,
isSelected,
setAttributes,
clientId,
} ) => {
const { url, service, label = '', rel } = attributes;
const {
Expand Down Expand Up @@ -178,7 +159,6 @@ const SocialLinkEdit = ( {
setAttributes={ setAttributes }
setPopover={ setPopover }
popoverAnchor={ popoverAnchor }
clientId={ clientId }
/>
) }
</li>
Expand Down

0 comments on commit 9ec1c11

Please sign in to comment.