From 4987cc53d0a8abf8a68b31aba559687dd4f420a8 Mon Sep 17 00:00:00 2001 From: Ryan Di Date: Tue, 9 Apr 2024 22:07:36 +0800 Subject: [PATCH] fix: include borders when testing insides of a shape (#7865) --- packages/excalidraw/element/collision.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/excalidraw/element/collision.ts b/packages/excalidraw/element/collision.ts index df3d9c928..51769a8b0 100644 --- a/packages/excalidraw/element/collision.ts +++ b/packages/excalidraw/element/collision.ts @@ -62,7 +62,9 @@ export const hitElementItself = ({ frameNameBound = null, }: HitTestArgs) => { let hit = shouldTestInside(element) - ? isPointInShape([x, y], shape) + ? // Since `inShape` tests STRICTLY againt the insides of a shape + // we would need `onShape` as well to include the "borders" + isPointInShape([x, y], shape) || isPointOnShape([x, y], shape, threshold) : isPointOnShape([x, y], shape, threshold); // hit test against a frame's name