diff --git a/packages/core/src/scene-graph-hit-test.ts b/packages/core/src/scene-graph-hit-test.ts index ab484732b..cb82b158a 100644 --- a/packages/core/src/scene-graph-hit-test.ts +++ b/packages/core/src/scene-graph-hit-test.ts @@ -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 diff --git a/src/composables/use-canvas-input.ts b/src/composables/use-canvas-input.ts index 04832ec37..0648b8be6 100644 --- a/src/composables/use-canvas-input.ts +++ b/src/composables/use-canvas-input.ts @@ -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') {