Skip to content

Commit

Permalink
fixed selection bug
Browse files Browse the repository at this point in the history
  • Loading branch information
egauzens committed Aug 20, 2023
1 parent 225e659 commit 2578b56
Showing 1 changed file with 19 additions and 10 deletions.
29 changes: 19 additions & 10 deletions src/components/DropdownMultiselect/src/DropdownMultiselect.vue
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,21 @@ export default {
this.$refs.tree.filter()
},
updateParentFacetsSelectedStatus() {
let visibleCheckedParents = this.visibleCheckedNodes.filter(visibleNode => {
return !visibleNode.label.includes('.')
})
let visibleCheckedChildren = this.visibleCheckedNodes.filter(visibleNode => {
return visibleNode.label.includes('.')
})
// First check for any subfacets that have a parent that is not set
visibleCheckedChildren.forEach(checkedChild => {
const parentLabel = checkedChild.label.split('.')[0]
if (!visibleCheckedParents.some(parent => parent.label == parentLabel)) {
this.$refs.tree.setChecked(checkedChild.id, true, true)
}
})
const halfCheckedNodes = this.$refs.tree.getHalfCheckedNodes()
// set the half checked nodes checked status based upon what facets are actually visible since navigating between tabs might
// cause some to be hidden so the parent facet should now possibly be checked/unchecked instead of half checked
Expand All @@ -265,21 +280,13 @@ export default {
}
})
const visibleCheckedParents = this.visibleCheckedNodes.filter(visibleNode => {
visibleCheckedParents = this.visibleCheckedNodes.filter(visibleNode => {
return !visibleNode.label.includes('.')
})
const visibleCheckedChildren = this.visibleCheckedNodes.filter(visibleNode => {
visibleCheckedChildren = this.visibleCheckedNodes.filter(visibleNode => {
return visibleNode.label.includes('.')
})
// Check for any subfacets that have a parent that is not set
visibleCheckedChildren.forEach(checkedChild => {
const parentLabel = checkedChild.label.split('.')[0]
if (!visibleCheckedParents.some(parent => parent.label == parentLabel)) {
this.$refs.tree.setChecked(checkedChild.id, true, true)
}
})
visibleCheckedParents.forEach(checkedParent => {
// If any children are unselected then select one deep so that the parent is half-checked
const visibleChildren = checkedParent.children.filter(child => this.allVisibleDataIds.includes(child.label))
Expand All @@ -299,6 +306,8 @@ export default {
})
if (alreadyCheckedChild != undefined) {
this.$refs.tree.setChecked(alreadyCheckedChild.id, true, true)
} else {
this.$refs.tree.setChecked(checkedParent.id, false)
}
}
})
Expand Down

0 comments on commit 2578b56

Please sign in to comment.