AI-native design editor. Open-source Figma alternative.
Fix missing import for section title hit testing
Danila Poyarkov60ed0f195d7e
diff --git a/src/composables/use-canvas-input.ts b/src/composables/use-canvas-input.tsindex 4d282e232..863622f94 100644--- a/src/composables/use-canvas-input.ts+++ b/src/composables/use-canvas-input.ts@@ -310,7 +310,7 @@ export function useCanvasInput(canvasRef: Ref<HTMLCanvasElement | null>, store:}// Hit test nodes- const hit = store.graph.hitTest(cx, cy, store.state.currentPageId)+ const hit = store.graph.hitTest(cx, cy, store.state.currentPageId, store.state.zoom)if (hit) {if (!store.state.selectedIds.has(hit.id) && !e.shiftKey) {store.select([hit.id])@@ -480,7 +480,7 @@ export function useCanvasInput(canvasRef: Ref<HTMLCanvasElement | null>, store:}cursorOverride.value = cursor- const hit = store.graph.hitTest(cx, cy)+ const hit = store.graph.hitTest(cx, cy, undefined, store.state.zoom)store.setHoveredNode(hit && !store.state.selectedIds.has(hit.id) ? hit.id : null)}@@ -820,7 +820,7 @@ export function useCanvasInput(canvasRef: Ref<HTMLCanvasElement | null>, store:function onDblClick(e: MouseEvent) {const { cx, cy } = getCoords(e)- const hit = store.graph.hitTest(cx, cy, store.state.currentPageId)+ const hit = store.graph.hitTest(cx, cy, store.state.currentPageId, store.state.zoom)if (hit && hit.type === 'TEXT') {store.select([hit.id])store.startTextEditing(hit.id)diff --git a/src/engine/scene-graph.ts b/src/engine/scene-graph.tsindex 5ad9ca294..f43876185 100644--- a/src/engine/scene-graph.ts+++ b/src/engine/scene-graph.ts@@ -1,3 +1,5 @@+import { SECTION_TITLE_HEIGHT, SECTION_TITLE_GAP } from '../constants'+export type { GUID, Color } from '../types'export type HandleMirroring = 'NONE' | 'ANGLE' | 'ANGLE_AND_LENGTH'@@ -360,9 +362,9 @@ export class SceneGraph {this.nodes.delete(id)}- hitTest(px: number, py: number, scopeId?: string): SceneNode | null {+ hitTest(px: number, py: number, scopeId?: string, zoom = 1): SceneNode | null {const scope = scopeId ?? this.rootId- return this.hitTestChildren(px, py, scope, 0, 0)+ return this.hitTestChildren(px, py, scope, 0, 0, zoom, false)}private hitTestChildren(@@ -370,7 +372,9 @@ export class SceneGraph {py: number,parentId: string,offsetX: number,- offsetY: number+ offsetY: number,+ zoom: number,+ insideSection: boolean): SceneNode | null {const parent = this.nodes.get(parentId)if (!parent) return null@@ -386,10 +390,26 @@ export class SceneGraph {// Check children first (deeper hit)if (CONTAINER_TYPES.has(child.type)) {- const deepHit = this.hitTestChildren(px, py, childId, ax, ay)+ const nested = insideSection || child.type === 'SECTION'+ const deepHit = this.hitTestChildren(px, py, childId, ax, ay, zoom, nested)if (deepHit) return deepHit}+ // Section title pill extends above (top-level) or inside (nested)+ if (child.type === 'SECTION') {+ const titleH = (SECTION_TITLE_HEIGHT + SECTION_TITLE_GAP) / zoom+ let titleTop: number+ if (insideSection) {+ titleTop = ay + SECTION_TITLE_GAP / zoom+ } else {+ titleTop = ay - titleH+ }+ const titleBottom = insideSection ? titleTop + SECTION_TITLE_HEIGHT / zoom : ay+ if (px >= ax && px <= ax + child.width && py >= titleTop && py <= titleBottom) {+ return child+ }+ }+if (px >= ax && px <= ax + child.width && py >= ay && py <= ay + child.height) {return child}