Skip to content

Commit

Permalink
ConceptList: Also watch list of ancestors to fix race condition (#670)
Browse files Browse the repository at this point in the history
  • Loading branch information
stefandesu committed Mar 1, 2022
1 parent bf4ad71 commit 599602e
Showing 1 changed file with 22 additions and 4 deletions.
26 changes: 22 additions & 4 deletions src/components/ConceptList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,18 @@ export default {
otherScheme() {
return getItem(this.selected.scheme[!this.isLeft])
},
ancestors() {
const ancestors = this.conceptSelectedFromStore && this.conceptSelectedFromStore.ancestors
if (!ancestors) {
return null
}
return ancestors.map(ancestor => {
if (!ancestor) {
return ancestor
}
return getItem(ancestor)
})
},
},
watch: {
conceptSelectedFromStore: {
Expand All @@ -155,6 +167,13 @@ export default {
},
deep: true,
},
// We need to watch ancestors as well because the previous watcher does not cover ancestors more than one step away.
ancestors: {
handler() {
this.conceptSelectedUpdated()
},
deep: true,
},
shown() {
this.conceptSelectedUpdated()
},
Expand Down Expand Up @@ -272,10 +291,9 @@ export default {
}
if (this.$jskos.isConcept(concept)) {
// Check if concept is fully loaded
if (!this.showChildren || (concept.ancestors && !concept.ancestors.includes(null))) {
if (!this.showChildren || (this.ancestors && !this.ancestors.includes(null))) {
let fullyLoaded = true
for (let ancestor of concept.ancestors || []) {
ancestor = getItem(ancestor)
for (let ancestor of this.ancestors || []) {
if (this.showChildren && (!ancestor.narrower || ancestor.narrower.includes(null))) {
fullyLoaded = false
}
Expand All @@ -284,7 +302,7 @@ export default {
this.shouldScroll = false
// Open ancestors
if (this.showChildren) {
for (let ancestor of concept.ancestors || []) {
for (let ancestor of this.ancestors || []) {
this.open(ancestor, this.isLeft, true)
}
}
Expand Down

0 comments on commit 599602e

Please sign in to comment.