Skip to content

Commit

Permalink
bind unlink shortcut
Browse files Browse the repository at this point in the history
  • Loading branch information
ntsekouras committed Jun 25, 2020
1 parent ccda6d9 commit 3a26505
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions packages/block-library/src/button/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,15 @@ function URLPicker( {
const urlIsSetandSelected = urlIsSet && isSelected;
const openLinkControl = () => {
setIsURLPickerOpen( true );

// prevents default behaviour for event
return false;
return false; // prevents default behaviour for event
};
const unlinkButton = () => {
setAttributes( {
url: undefined,
linkTarget: undefined,
rel: undefined,
} );
setIsURLPickerOpen( false );
};
const linkControl = ( isURLPickerOpen || urlIsSetandSelected ) && (
<Popover
Expand Down Expand Up @@ -118,13 +124,7 @@ function URLPicker( {
icon={ linkOff }
title={ __( 'Unlink' ) }
shortcut={ displayShortcut.primaryShift( 'k' ) }
onClick={ () =>
setAttributes( {
url: undefined,
linkTarget: undefined,
rel: undefined,
} )
}
onClick={ unlinkButton }
isActive={ true }
/>
) }
Expand All @@ -135,6 +135,7 @@ function URLPicker( {
bindGlobal
shortcuts={ {
[ rawShortcut.primary( 'k' ) ]: openLinkControl,
[ rawShortcut.primaryShift( 'k' ) ]: unlinkButton,
} }
/>
) }
Expand Down

0 comments on commit 3a26505

Please sign in to comment.