Fix group selection: single click selects group, double click enters, locked groups block enter

This commit is contained in:
Anton A S 2026-03-15 12:48:07 +03:00 committed by Danila Poyarkov
parent 116acb5cfa
commit 01235c0d84
2 changed files with 18 additions and 6 deletions

View file

@ -40,8 +40,12 @@ function hitTestTransparentContainer(
ay: number,
deep: boolean
): SceneNode | null {
const deepHit = hitTestChildren(graph, px, py, childId, ax, ay, deep)
if (deepHit) return deepHit
const childHit = hitTestChildren(graph, px, py, childId, ax, ay, deep)
if (childHit) {
if (!deep && child.type === 'GROUP') return child
if (child.locked) return child
return childHit
}
if (child.type === 'GROUP') return null
if (containsPoint(px, py, ax, ay, child) && hasVisibleFillOrStroke(child)) return child
return null

View file

@ -1082,10 +1082,18 @@ export function useCanvasInput(
if (store.state.editingTextId) return
const { cx, cy } = getCoords(e)
const hit =
hitTestSectionTitle(cx, cy) ??
hitTestComponentLabel(cx, cy) ??
store.graph.hitTestDeep(cx, cy, store.state.currentPageId)
const selectedId = store.state.selectedIds.size === 1
? [...store.state.selectedIds][0]
: undefined
const selectedNode = selectedId ? store.graph.getNode(selectedId) : undefined
const canEnter = selectedNode && selectedId && store.graph.isContainer(selectedId) && !selectedNode.locked
const hit = canEnter
? store.graph.hitTestDeep(cx, cy, selectedId)
: (hitTestSectionTitle(cx, cy) ??
hitTestComponentLabel(cx, cy) ??
store.graph.hitTestDeep(cx, cy, store.state.currentPageId))
if (!hit) return
if (hit.type === 'TEXT') {