fix: Prevent layer interactions when not editing

Guard layer selection, cursor, and resize interactions behind
the editing state to avoid unintended modifications in view mode.
This commit is contained in:
hyper
2026-08-07 11:24:57 +08:00
parent 6bcdca3a77
commit a69a41875d
2 changed files with 11 additions and 3 deletions
@@ -87,6 +87,8 @@ export function useLayerInteraction(
const handleLayerClick = (index: number, e: MouseEvent) => {
e.stopPropagation();
if (!store.state.isEditing || store.state.fixed) return;
const currentlySelected = store.state.selectedLayer;
if (currentlySelected === index) {
@@ -100,6 +102,7 @@ export function useLayerInteraction(
const handleCardClick = (e: MouseEvent, cardEl: HTMLElement) => {
if (store.state.draggingState) return;
if (!store.state.isEditing || store.state.fixed) return;
const { gridX, gridY } = calculateGridCoords(e, cardEl);
const overlapping = getOverlappingLayers(gridX, gridY);
@@ -147,6 +150,7 @@ export function useLayerInteraction(
edge?: "n" | "s" | "e" | "w",
e?: MouseEvent,
) => {
if (!store.state.isEditing || store.state.fixed) return;
if (store.state.selectedLayer === null) return;
if (e) e.stopPropagation();