From 8bbeb32e8779ab2d7d34f20d3f282c4b57a67f04 Mon Sep 17 00:00:00 2001 From: Michal Srb Date: Sun, 9 Aug 2020 00:51:41 -0700 Subject: [PATCH] Fix text selection broken by PR1899 (#2011) --- src/element/collision.ts | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/element/collision.ts b/src/element/collision.ts index 8faa5553..562a9df2 100644 --- a/src/element/collision.ts +++ b/src/element/collision.ts @@ -48,9 +48,12 @@ export const hitTest = ( ): boolean => { // How many pixels off the shape boundary we still consider a hit const threshold = 10 / appState.zoom; - const check = isElementDraggableFromInside(element, appState) - ? isInsideCheck - : isNearCheck; + const check = + element.type === "text" + ? isStrictlyInside + : isElementDraggableFromInside(element, appState) + ? isInsideCheck + : isNearCheck; const point: Point = [x, y]; return hitTestPointAgainstElement({ element, point, threshold, check }); }; @@ -119,6 +122,10 @@ export const distanceToBindableElement = ( } }; +const isStrictlyInside = (distance: number, threshold: number): boolean => { + return distance < 0; +}; + const isInsideCheck = (distance: number, threshold: number): boolean => { return distance < threshold; };