From 2b35bad45d4437bd4c647ab53afd8a8a2af4caee Mon Sep 17 00:00:00 2001 From: hz-tyfoon Date: Mon, 15 May 2023 21:15:00 +0600 Subject: [PATCH] fix: clicking 'cancel' button still shows the updated change - fixed: when making some change after opening the 'link control modal' & without applying/submitting it, when the 'cancel' button is clicked it show's that the changes already applied even though it's cancelled (although the updated changes aren't really applied but, still it's a misleading UI so fixed it) --- .../block-editor/src/components/link-control/index.js | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/packages/block-editor/src/components/link-control/index.js b/packages/block-editor/src/components/link-control/index.js index 4c40f171068e0..5eaecedcce249 100644 --- a/packages/block-editor/src/components/link-control/index.js +++ b/packages/block-editor/src/components/link-control/index.js @@ -237,19 +237,13 @@ function LinkControl( { } }; - const resetInternalValues = () => { - setInternalUrlInputValue( newValue?.url ); - setInternalTextInputValue( newValue?.title ); - }; - const handleCancel = ( event ) => { event.preventDefault(); event.stopPropagation(); - // Ensure that any unsubmitted input changes are reset. - resetInternalValues(); + setNewValue( value ); - if ( hasLinkValue ) { + if ( value?.url?.trim()?.length > 0 ) { // If there is a link then exist editing mode and show preview. stopEditing(); } else {