Fix condition where linear and freedraw cannot be unselected

This commit is contained in:
Mark Tolmacs 2025-05-08 11:17:03 +02:00
parent 8157b570db
commit 65cecf041a
No known key found for this signature in database

View File

@ -14,6 +14,10 @@ import { elementCenterPoint } from "@excalidraw/common";
import { distanceToElement } from "@excalidraw/element/distance"; import { distanceToElement } from "@excalidraw/element/distance";
import { isLinearElement } from "@excalidraw/excalidraw";
import { isFreeDrawElement } from "@excalidraw/element/typeChecks";
import { isPathALoop } from "@excalidraw/element/shapes";
import type { ExcalidrawElement } from "@excalidraw/element/types"; import type { ExcalidrawElement } from "@excalidraw/element/types";
import type { Curve } from "@excalidraw/math"; import type { Curve } from "@excalidraw/math";
@ -36,6 +40,14 @@ export const isPointInShape = (
point: GlobalPoint, point: GlobalPoint,
element: ExcalidrawElement, element: ExcalidrawElement,
) => { ) => {
if (
(isLinearElement(element) || isFreeDrawElement(element)) &&
!isPathALoop(element.points)
) {
// There isn't any "inside" for a non-looping path
return false;
}
const intersections = intersectElementWithLineSegment( const intersections = intersectElementWithLineSegment(
element, element,
lineSegment(elementCenterPoint(element), point), lineSegment(elementCenterPoint(element), point),