Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Use mouse down
  • Loading branch information
ellatrix committed Nov 25, 2020
commit 360e22a6d9447854e1647b0c7cb25a299362bb30
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ const isTabbableTextField = overEvery( [

export function useCanvasClickRedirect( ref ) {
useEffect( () => {
function onClick( event ) {
// Only handle clicks directly on the canvas itself, not on content.
function onMouseDown( event ) {
// Only handle clicks on the canvas, not the content.
if ( event.target !== ref.current ) {
return;
}
Expand All @@ -38,12 +38,13 @@ export function useCanvasClickRedirect( ref ) {
}

placeCaretAtHorizontalEdge( target, true );
event.preventDefault();
}

ref.current.addEventListener( 'click', onClick );
ref.current.addEventListener( 'mousedown', onMouseDown );

return () => {
ref.current.removeEventListener( 'click', onClick );
ref.current.addEventListener( 'mousedown', onMouseDown );
};
}, [] );
}