From 85ec8c60f4905077a9a3f9750bc942c74168c3a5 Mon Sep 17 00:00:00 2001 From: Delowar Hossain Date: Wed, 8 Dec 2021 01:12:33 +0600 Subject: [PATCH] Fix: Clicking On Backspace Makes Reusable Block Modal Disappear See: #36513 --- package-lock.json | 1 + packages/reusable-blocks/package.json | 1 + .../reusable-block-convert-button.js | 7 +++++++ 3 files changed, 9 insertions(+) diff --git a/package-lock.json b/package-lock.json index b1a0b613c6afda..53d6ef595199e4 100644 --- a/package-lock.json +++ b/package-lock.json @@ -19700,6 +19700,7 @@ "@wordpress/element": "file:packages/element", "@wordpress/i18n": "file:packages/i18n", "@wordpress/icons": "file:packages/icons", + "@wordpress/keycodes": "file:packages/keycodes", "@wordpress/notices": "file:packages/notices", "@wordpress/url": "file:packages/url", "lodash": "^4.17.21" diff --git a/packages/reusable-blocks/package.json b/packages/reusable-blocks/package.json index 8acebdbb869a74..ea87a85f86c03e 100644 --- a/packages/reusable-blocks/package.json +++ b/packages/reusable-blocks/package.json @@ -37,6 +37,7 @@ "@wordpress/element": "file:../element", "@wordpress/i18n": "file:../i18n", "@wordpress/icons": "file:../icons", + "@wordpress/keycodes": "file:../keycodes", "@wordpress/notices": "file:../notices", "@wordpress/url": "file:../url", "lodash": "^4.17.21" diff --git a/packages/reusable-blocks/src/components/reusable-blocks-menu-items/reusable-block-convert-button.js b/packages/reusable-blocks/src/components/reusable-blocks-menu-items/reusable-block-convert-button.js index ab7d8b12e44168..ad4e4f3c26d0ba 100644 --- a/packages/reusable-blocks/src/components/reusable-blocks-menu-items/reusable-block-convert-button.js +++ b/packages/reusable-blocks/src/components/reusable-blocks-menu-items/reusable-block-convert-button.js @@ -20,6 +20,7 @@ import { useDispatch, useSelect } from '@wordpress/data'; import { __ } from '@wordpress/i18n'; import { store as noticesStore } from '@wordpress/notices'; import { store as coreStore } from '@wordpress/core-data'; +import { BACKSPACE } from '@wordpress/keycodes'; /** * Internal dependencies @@ -143,6 +144,12 @@ export default function ReusableBlockConvertButton( { label={ __( 'Name' ) } value={ title } onChange={ setTitle } + onKeyDown={ ( event ) => { + const { keyCode } = event; + if ( keyCode === BACKSPACE ) { + event.stopPropagation(); + } + } } />