Skip to content

Commit

Permalink
fix: fix layer name undo
Browse files Browse the repository at this point in the history
  • Loading branch information
kylehue committed Mar 27, 2024
1 parent 03bca6f commit b407f1a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/panes/layer-area/layer-item.vue
Original file line number Diff line number Diff line change
Expand Up @@ -164,9 +164,11 @@ function handleLayerNameInput() {
"layer-name",
() => {
props.layer.name = oldName;
layerNameInputValue.value = oldName;
},
() => {
props.layer.name = newName;
layerNameInputValue.value = newName;
}
);
}
Expand Down
6 changes: 5 additions & 1 deletion src/store/project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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);
}
Expand Down

0 comments on commit b407f1a

Please sign in to comment.