mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-05-03 10:00:07 -04:00
fix: linear elements not selected on pointer up from hitting its bound text (#8285)
Co-authored-by: dwelle <5153846+dwelle@users.noreply.github.com>
This commit is contained in:
parent
2427e622b0
commit
7b36de0476
4 changed files with 42 additions and 38 deletions
|
@ -18,6 +18,7 @@ import {
|
|||
isImageElement,
|
||||
isTextElement,
|
||||
} from "./typeChecks";
|
||||
import { getBoundTextShape } from "../shapes";
|
||||
|
||||
export const shouldTestInside = (element: ExcalidrawElement) => {
|
||||
if (element.type === "arrow") {
|
||||
|
@ -97,6 +98,12 @@ export const hitElementBoundingBoxOnly = (
|
|||
) => {
|
||||
return (
|
||||
!hitElementItself(hitArgs) &&
|
||||
// bound text is considered part of the element (even if it's outside the bounding box)
|
||||
!hitElementBoundText(
|
||||
hitArgs.x,
|
||||
hitArgs.y,
|
||||
getBoundTextShape(hitArgs.element, elementsMap),
|
||||
) &&
|
||||
hitElementBoundingBox(hitArgs.x, hitArgs.y, hitArgs.element, elementsMap)
|
||||
);
|
||||
};
|
||||
|
@ -105,6 +112,6 @@ export const hitElementBoundText = (
|
|||
x: number,
|
||||
y: number,
|
||||
textShape: GeometricShape | null,
|
||||
) => {
|
||||
return textShape && isPointInShape([x, y], textShape);
|
||||
): boolean => {
|
||||
return !!textShape && isPointInShape([x, y], textShape);
|
||||
};
|
||||
|
|
|
@ -635,8 +635,7 @@ export const getMaxCharWidth = (font: FontString) => {
|
|||
|
||||
export const getBoundTextElementId = (container: ExcalidrawElement | null) => {
|
||||
return container?.boundElements?.length
|
||||
? container?.boundElements?.filter((ele) => ele.type === "text")[0]?.id ||
|
||||
null
|
||||
? container?.boundElements?.find((ele) => ele.type === "text")?.id || null
|
||||
: null;
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue