🐛 Fix nodes panel reactivity bug (#1972)

* add keys

* fix nodes panel reactivity bug

* fix lint issues
This commit is contained in:
Mutasem Aldmour 2021-07-08 07:46:20 +02:00 committed by GitHub
parent a74fc78ed3
commit a842e4bc0a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 2 deletions

View file

@ -8,7 +8,7 @@
@before-leave="beforeLeave"
@leave="leave"
>
<div v-for="(item, index) in elements" :key="item.key" :class="item.type">
<div v-for="(item, index) in elements" :key="item.key" :class="item.type" :data-key="item.key">
<CreatorItem
:item="item"
:active="activeIndex === index && !disabled"

View file

@ -29,9 +29,17 @@ export default Vue.extend({
props: [
'active',
],
data() {
return {
allNodeTypes: [],
};
},
computed: {
nodeTypes(): INodeTypeDescription[] {
return this.$store.getters.allNodeTypes;
},
visibleNodeTypes(): INodeTypeDescription[] {
return this.$store.getters.allNodeTypes
return this.allNodeTypes
.filter((nodeType: INodeTypeDescription) => {
return !HIDDEN_NODES.includes(nodeType.name);
});
@ -73,6 +81,13 @@ export default Vue.extend({
this.$emit('nodeTypeSelected', nodeTypeName);
},
},
watch: {
nodeTypes(newList, prevList) {
if (prevList.length === 0) {
this.allNodeTypes = newList;
}
},
},
});
</script>