Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
10 changes: 4 additions & 6 deletions packages/editor/src/lib/editor/Editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5330,19 +5330,17 @@ export class Editor extends EventEmitter<TLEventMap> {
}
}

if (this.isShapeFrame(shape)) {
if (this.isShapeOfType(shape, 'frame')) {
Comment thread
kaznaan marked this conversation as resolved.
// On the rare case that we've hit a frame (not its label), test again hitInside to be forced true;
// this prevents clicks from passing through the body of a frame to shapes behind it.

// If the hit is within the frame's outer margin, then select the frame
const distance = geometry.distanceToPoint(pointInShapeSpace, hitFrameInside)
const isGrid = (shape as any).type === 'grid'
if (
!isGrid &&
(hitFrameInside
hitFrameInside
? (distance > 0 && distance <= outerMargin) ||
(distance <= 0 && distance > -innerMargin)
: distance > 0 && distance <= outerMargin)
: distance > 0 && distance <= outerMargin
) {
return inMarginClosestToEdgeHit || shape
}
Expand All @@ -5357,7 +5355,7 @@ export class Editor extends EventEmitter<TLEventMap> {
return (
inMarginClosestToEdgeHit ||
inHollowSmallestAreaHit ||
(hitFrameInside || isGrid ? shape : undefined)
(hitFrameInside ? shape : undefined)
)
}
continue
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ export class Brushing extends StateNode {

// If we're in wrap mode and the brush did not fully encloses the shape, it's a miss
// We also skip frames unless we've completely selected the frame.
if (isWrapping || editor.isShapeFrame(shape)) {
if (editor.isShapeFrame(shape)) {
Comment thread
kaznaan marked this conversation as resolved.
continue testAllShapes
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Group2d, StateNode, TLPointerEventInfo, TLShape } from '@tldraw/editor'
import { StateNode, TLPointerEventInfo, TLShape } from '@tldraw/editor'
import { isOverArrowLabel } from '../../../shapes/arrow/arrowLabel'
import { getTextLabels } from '../../../utils/shapes/shapes'

Expand All @@ -11,7 +11,6 @@ export class PointingShape extends StateNode {

didCtrlOnEnter = false
didSelectOnEnter = false
didHitGridLabel = false

override onEnter(info: TLPointerEventInfo & { target: 'shape' }) {
const selectedShapeIds = this.editor.getSelectedShapeIds()
Expand All @@ -23,19 +22,6 @@ export class PointingShape extends StateNode {
this.hitShape = info.shape
this.isDoubleClick = false
this.didCtrlOnEnter = accelKey
this.didHitGridLabel = false
if ((info.shape as any).type === 'grid') {
const geometry = this.editor.getShapeGeometry(info.shape)
if (geometry instanceof Group2d) {
const pointInShapeSpace = this.editor.getPointInShapeSpace(info.shape, currentPagePoint)
for (const child of geometry.children) {
if (child.isLabel && child.isPointInBounds(pointInShapeSpace)) {
this.didHitGridLabel = true
break
}
}
}
}
const outermostSelectingShape = this.editor.getOutermostSelectableShape(info.shape)
const selectedAncestor = this.editor.findShapeAncestor(outermostSelectingShape, (parent) =>
selectedShapeIds.includes(parent.id)
Expand Down Expand Up @@ -231,9 +217,6 @@ export class PointingShape extends StateNode {

if (this.didCtrlOnEnter) {
this.parent.transition('brushing', info)
} else if (this.didSelectOnEnter && (this.hitShape as any).type === 'grid' && !this.didHitGridLabel) {
Comment thread
graycrawford marked this conversation as resolved.
this.editor.setSelectedShapes([])
this.parent.transition('brushing', { ...info, target: 'canvas' as const })
} else {
this.startTranslating(info)
}
Expand Down
Loading