Skip to content

Commit

Permalink
remove unused deps, better function naming
Browse files Browse the repository at this point in the history
  • Loading branch information
draganescu committed Jan 26, 2024
1 parent 449dcf3 commit 4ca9bea
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions packages/format-library/src/link/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ function Edit( {
return;
}

function handleClick( event ) {
function handleMouseUp( event ) {
// There is a situation whereby there is an existing link in the rich text
// and the user clicks on the leftmost edge of that link and fails to activate
// the link format, but the click event still fires on the `<a>` element.
Expand All @@ -62,27 +62,24 @@ function Edit( {
setAddingLink( true );
}

const removeAddingLink = () => {
const handleMouseDown = () => {
setAddingLink( false );
};

editableContentElement.addEventListener(
'mousedown',
removeAddingLink
);
editableContentElement.addEventListener( 'mouseup', handleClick );
editableContentElement.addEventListener( 'mousedown', handleMouseDown );
editableContentElement.addEventListener( 'mouseup', handleMouseUp );

return () => {
editableContentElement.removeEventListener(
'mousedown',
removeAddingLink
handleMouseDown
);
editableContentElement.removeEventListener(
'mouseup',
handleClick
handleMouseUp
);
};
}, [ contentRef, isActive, onFocus, addingLink ] );
}, [ contentRef, isActive ] );

function addLink( target ) {
const text = getTextContent( slice( value ) );
Expand Down

0 comments on commit 4ca9bea

Please sign in to comment.