Skip to content

Commit

Permalink
fix: clicking 'cancel' button still shows the updated change
Browse files Browse the repository at this point in the history
 - 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)
  • Loading branch information
hz-tyfoon committed May 15, 2023
1 parent 9a01925 commit 2b35bad
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions packages/block-editor/src/components/link-control/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 2b35bad

Please sign in to comment.