From b407f1ae1adfd7062e4c20687ca51f27a55bf2f8 Mon Sep 17 00:00:00 2001 From: kylehue Date: Wed, 27 Mar 2024 21:28:06 +0800 Subject: [PATCH] fix: fix layer name undo --- src/panes/layer-area/layer-item.vue | 2 ++ src/store/project.ts | 6 +++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/panes/layer-area/layer-item.vue b/src/panes/layer-area/layer-item.vue index 4654265..84c5bdf 100644 --- a/src/panes/layer-area/layer-item.vue +++ b/src/panes/layer-area/layer-item.vue @@ -164,9 +164,11 @@ function handleLayerNameInput() { "layer-name", () => { props.layer.name = oldName; + layerNameInputValue.value = oldName; }, () => { props.layer.name = newName; + layerNameInputValue.value = newName; } ); } diff --git a/src/store/project.ts b/src/store/project.ts index 1369747..2bdc830 100644 --- a/src/store/project.ts +++ b/src/store/project.ts @@ -194,6 +194,10 @@ export const useProjectStore = defineStore("project", () => { layer.matrix.setSeparator(_matrixSeparator.value); _layers.unshift(layer); + if (_layers.length === 1) { + setSelectedLayer(layer); + } + makeLayersMatrixSizeUniform(); return layer; } @@ -204,7 +208,7 @@ export const useProjectStore = defineStore("project", () => { const targetIndex = clamp(currentIndex + step, 0, _layers.length - 1); const isSelected = _selectedLayer.value?.id === layer.id; - deleteLayer(layer); + _layers.splice(currentIndex, 1); _layers.splice(targetIndex, 0, layer); if (isSelected) setSelectedLayer(layer); }